We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running with flutter 3.24 I started receiving this error:
The following assertion was thrown during performLayout(): The _SliderLayout custom multichild layout delegate provided invalid box constraints for the child with id "track". FlutterError The minimum width and height must be greater than or equal to zero. The maximum width must be greater than or equal to the minimum width. The maximum height must be greater than or equal to the minimum height. The relevant error-causing widget was: CustomMultiChildLayout CustomMultiChildLayout:file:///home/tcna/dev/workspace-automation/.config/flutter_workspace/pub_cache/hosted/pub.dev /flutter_colorpicker-1.1.0/lib/src/palette.dart:1115:14 When the exception was thrown, this was the stack: #0 MultiChildLayoutDelegate.layoutChild.<anonymous closure> (package:flutter/src/rendering/custom_layout.dart:161:9) #1 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:172:6) #2 _SliderLayout.performLayout (package:flutter_colorpicker/src/palette.dart:584:5) #3 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:237:7) #4 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:404:14) #5 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #6 _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:371:14) #7 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #8 RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:291:14) #9 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #10 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:61:11) #11 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:985:73) #12 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:1051:32) #13 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #14 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:61:11) #15 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:1009:71) #16 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:1051:32) #17 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #18 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:234:12) #19 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #20 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:61:11) #21 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:985:73) #22 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:1051:32) #23 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #24 RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:291:14) #25 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #26 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:61:11) #27 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:985:73) #28 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:1051:32) #29 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #30 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:61:11) #31 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:985:73) #32 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:1051:32) #33 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #34 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:61:11) #35 RenderStack._computeSize (package:flutter/src/rendering/stack.dart:595:43) #36 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:622:12) #37 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #38 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:173:12) #39 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:1092:7) #40 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:237:7) #41 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:404:14) #42 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #43 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #44 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #45 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #46 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1448:11) #47 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #48 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #49 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #50 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #51 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #52 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #53 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #54 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #55 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #56 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #57 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #58 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #59 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #60 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #61 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #62 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #63 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #64 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #65 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #66 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #67 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3728:13) #68 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #69 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #70 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #71 _RenderTheaterMixin.layoutChild (package:flutter/src/widgets/overlay.dart:1002:13) #72 _RenderTheater.performLayout (package:flutter/src/widgets/overlay.dart:1311:9) #73 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #74 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #75 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #76 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #77 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #78 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #79 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #80 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #81 RenderCustomPaint.performLayout (package:flutter/src/rendering/custom_paint.dart:569:11) #82 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #83 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #84 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #85 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #86 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #87 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #88 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #89 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #90 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #91 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #92 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #93 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:21) #94 RenderObject.layout (package:flutter/src/rendering/object.dart:2608:7) #95 RenderView.performLayout (package:flutter/src/rendering/view.dart:281:14) #96 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2446:7) #97 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1052:18) #98 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1065:15) #99 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:602:23) #100 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1164:13) #101 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:468:5) #102 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1397:15) #103 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1318:9) #104 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:1040:9) #105 PlatformDispatcher.scheduleWarmUpFrame.<anonymous closure> (dart:/platform_dispatcher.dart:837:16) #116 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12) (elided 10 frames from class _Timer, dart:async, and dart:async-patch) The following RenderObject was being processed when the exception was fired: RenderCustomMultiChildLayoutBox#f3bc9 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE: creator: CustomMultiChildLayout ← LayoutBuilder ← ColorPickerSlider ← SizedBox ← Column ← Expanded ← Row ← Padding ← Column ← ColorPicker ← ConstrainedBox ← Container ← ⋯ parentData: offset=Offset(0.0, 0.0) (can use size) constraints: BoxConstraints(w=25.0, h=40.0) size: Size(25.0, 40.0) This RenderObject had the following descendants (showing up to depth 5): child 1: RenderClipRRect#7eeb0 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE child: RenderCustomPaint#c9024 NEEDS-LAYOUT NEEDS-PAINT child 2: RenderTransform#fcc49 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE child: RenderCustomPaint#d7947 NEEDS-LAYOUT NEEDS-PAINT child 3: _RenderLayoutBuilder#1707d NEEDS-LAYOUT NEEDS-PAINT
AI had me change the class _SlliderLayout to the following and fixed my issue (in palette.dart):
class _SliderLayout extends MultiChildLayoutDelegate { static const String track = 'track'; static const String thumb = 'thumb'; static const String gestureContainer = 'gesturecontainer'; @override void performLayout(Size size) { // Track constraints double trackWidth = size.width - 30.0; double trackHeight = size.height / 5; if (trackWidth < 0) trackWidth = 0; if (trackHeight < 0) trackHeight = 0; layoutChild( track, BoxConstraints.tightFor( width: trackWidth, height: trackHeight, ), ); positionChild(track, Offset(15.0, size.height * 0.4)); // Thumb constraints double thumbHeight = size.height / 4; if (thumbHeight < 0) thumbHeight = 0; layoutChild( thumb, BoxConstraints.tightFor(width: 5.0, height: thumbHeight), ); positionChild(thumb, Offset(0.0, size.height * 0.4)); // Gesture container constraints double gestureContainerWidth = size.width; double gestureContainerHeight = size.height; if (gestureContainerWidth < 0) gestureContainerWidth = 0; if (gestureContainerHeight < 0) gestureContainerHeight = 0; layoutChild( gestureContainer, BoxConstraints.tightFor(width: gestureContainerWidth, height: gestureContainerHeight), ); positionChild(gestureContainer, Offset.zero); } @override bool shouldRelayout(_SliderLayout oldDelegate) => false; }
The text was updated successfully, but these errors were encountered:
@mchome will you accept a PR with this change?
diff --git a/lib/src/palette.dart b/lib/src/palette.dart index 7bc9b33..014769f 100644 --- a/lib/src/palette.dart +++ b/lib/src/palette.dart @@ -579,24 +579,42 @@ class _SliderLayout extends MultiChildLayoutDelegate { static const String thumb = 'thumb'; static const String gestureContainer = 'gesturecontainer'; - @override +@override void performLayout(Size size) { + // Track constraints + double trackWidth = size.width - 30.0; + double trackHeight = size.height / 5; + if (trackWidth < 0) trackWidth = 0; + if (trackHeight < 0) trackHeight = 0; + layoutChild( track, BoxConstraints.tightFor( - width: size.width - 30.0, - height: size.height / 5, + width: trackWidth, + height: trackHeight, ), ); positionChild(track, Offset(15.0, size.height * 0.4)); + + // Thumb constraints + double thumbHeight = size.height / 4; + if (thumbHeight < 0) thumbHeight = 0; + layoutChild( thumb, - BoxConstraints.tightFor(width: 5.0, height: size.height / 4), + BoxConstraints.tightFor(width: 5.0, height: thumbHeight), ); positionChild(thumb, Offset(0.0, size.height * 0.4)); + + // Gesture container constraints + double gestureContainerWidth = size.width; + double gestureContainerHeight = size.height; + if (gestureContainerWidth < 0) gestureContainerWidth = 0; + if (gestureContainerHeight < 0) gestureContainerHeight = 0; + layoutChild( gestureContainer, - BoxConstraints.tightFor(width: size.width, height: size.height), + BoxConstraints.tightFor(width: gestureContainerWidth, height: gestureContainerHeight), ); positionChild(gestureContainer, Offset.zero); }
Sorry, something went wrong.
No branches or pull requests
Running with flutter 3.24 I started receiving this error:
AI had me change the class _SlliderLayout to the following and fixed my issue (in palette.dart):
The text was updated successfully, but these errors were encountered: