#flutter #dart #singlechildscrollview
#flutter #dart #singlechildscrollview
Вопрос:
Когда я пытаюсь деформировать мой ListView внутри SingleChildScrollView. Я не хочу, чтобы мой listViewBuilder прокручивался отдельно. Вот почему это изменение физики и shrinkWarp (я не понимаю, почему это изменилось). Я хочу, чтобы два некролируемых ListView.builder прокручивались за один ход, возможно, путем обертывания его внутри SingleChildScrollView.
══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
When a column is in a parent that does not provide a finite height constraint, for example if it is
in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a
flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining
space in the vertical direction.
These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child
cannot simultaneously expand to fit its parent.
Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible
children (using Flexible rather than Expanded). This will allow the flexible children to size
themselves to less than the infinite remaining space they would otherwise be forced to take, and
then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum
constraints provided by the parent.
If this message did not help you determine the problem, consider using debugDumpRenderTree():
https://flutter.dev/debugging/#rendering-layer
http://api.flutter.dev/flutter/rendering/debugDumpRenderTree.html
The affected RenderFlex is:
RenderFlex#bf474 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE(creator: Column ← _SingleChildViewport ← IgnorePointer-[GlobalKey#a96e8] ← Semantics ← _PointerListener ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#2d1ee] ← _PointerListener ← Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#be83e] ← ⋯, parentData: <none> (can use size), constraints: BoxConstraints(w=360.0, 0.0<=h<=Infinity), size: MISSING, direction: vertical, mainAxisAlignment: start, mainAxisSize: max, crossAxisAlignment: center, verticalDirection: down)
The creator information is set to:
Column ← _SingleChildViewport ← IgnorePointer-[GlobalKey#a96e8] ← Semantics ← _PointerListener ←
Listener ← _GestureSemantics ←
RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#2d1ee] ← _PointerListener ← Listener
← _ScrollableScope ← _ScrollSemantics-[GlobalKey#be83e] ← ⋯
The nearest ancestor providing an unbounded width constraint is: _RenderSingleChildViewport#7d98f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
needs compositing
creator: _SingleChildViewport ← IgnorePointer-[GlobalKey#a96e8] ← Semantics ← _PointerListener ←
Listener ← _GestureSemantics ←
RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#2d1ee] ← _PointerListener ← Listener
← _ScrollableScope ← _ScrollSemantics-[GlobalKey#be83e] ← RepaintBoundary ← ⋯
parentData: <none> (can use size)
constraints: BoxConstraints(w=360.0, h=471.0)
size: MISSING
See also: https://flutter.dev/layout/
If none of the above helps enough to fix this problem, please don't hesitate to file a bug:
https://github.com/flutter/flutter/issues/new?template=BUG.md
The relevant error-causing widget was:
Column file:///D:/Other/App/Flutter/flash/lib/main_screens/tabs/today_tab.dart:12:14
When the exception was thrown, this was the stack:
#0 RenderFlex.performLayout.<anonymous closure> (package:flutter/src/rendering/flex.dart:712:11)
#1 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:739:10)
#2 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#3 _RenderSingleChildViewport.performLayout (package:flutter/src/widgets/single_child_scroll_view.dart:544:13)
#4 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#5 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#6 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#7 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#8 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#9 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#10 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#11 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#12 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#13 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#14 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#15 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#16 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#17 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#18 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#19 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#20 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#21 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#22 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#23 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#24 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#25 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#26 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#27 RenderSliverFixedExtentBoxAdaptor.performLayout (package:flutter/src/rendering/sliver_fixed_extent_list.dart:248:18)
#28 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#29 RenderSliverEdgeInsetsPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:137:11)
#30 _RenderSliverFractionalPadding.performLayout (package:flutter/src/widgets/sliver_fill.dart:170:11)
#31 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#32 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:471:13)
#33 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1465:12)
#34 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1374:20)
#35 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#36 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#37 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#38 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#39 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#40 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#41 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#42 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#43 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#44 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#45 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#46 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#47 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#48 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#49 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#50 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#51 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#52 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#53 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#54 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:173:11)
#55 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:495:7)
#56 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:242:7)
#57 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:401:14)
#58 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#59 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#60 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#61 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#62 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1269:11)
#63 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#64 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:209:11)
#65 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#66 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:173:11)
#67 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:495:7)
#68 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:242:7)
#69 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:401:14)
#70 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#71 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#72 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#73 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#74 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1269:11)
#75 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#76 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#77 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#78 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#79 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#80 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#81 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#82 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#83 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#84 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#85 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#86 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#87 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#88 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#89 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#90 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#91 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3228:13)
#92 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#93 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#94 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#95 _RenderTheatre.performLayout (package:flutter/src/widgets/overlay.dart:702:15)
#96 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#97 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#98 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#99 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#100 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#101 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#102 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#103 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#104 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#105 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
#106 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#107 _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:301:13)
#108 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#109 _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:301:13)
#110 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#111 RenderView.performLayout (package:flutter/src/rendering/view.dart:170:13)
#112 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1632:7)
#113 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:889:18)
#114 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:404:19)
#115 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:867:13)
#116 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:286:5)
#117 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1117:15)
#118 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1056:9)
#119 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:865:7)
(elided 4 frames from class _RawReceivePortImpl, class _Timer, and dart:async-patch)
The following RenderObject was being processed when the exception was fired: RenderFlex#bf474 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
creator: Column ← _SingleChildViewport ← IgnorePointer-[GlobalKey#a96e8] ← Semantics ←
_PointerListener ← Listener ← _GestureSemantics ←
RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#2d1ee] ← _PointerListener ← Listener
← _ScrollableScope ← _ScrollSemantics-[GlobalKey#be83e] ← ⋯
parentData: <none> (can use size)
constraints: BoxConstraints(w=360.0, 0.0<=h<=Infinity)
size: MISSING
direction: vertical
mainAxisAlignment: start
mainAxisSize: max
crossAxisAlignment: center
verticalDirection: down
This RenderObject had the following descendants (showing up to depth 5):
child 1: RenderRepaintBoundary#1afda NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderCustomPaint#35c8e NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderRepaintBoundary#91327 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: _RenderScrollSemantics#85e9b NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderPointerListener#a8cff NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child 2: RenderRepaintBoundary#94ff7 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderCustomPaint#064c6 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderRepaintBoundary#032ad NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: _RenderScrollSemantics#2473a NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderPointerListener#8713b NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: RenderBox was not laid out: RenderFlex#bf474 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: _RenderSingleChildViewport#7d98f NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#17a3e NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#434ed NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
When a column is in a parent that does not provide a finite height constraint, for example if it is in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining space in the vertical direction.
These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child cannot simultaneously expand to fit its parent.
Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible children (using Flexible rather than Expanded). This will allow the flexible children to size themselves to less than the infinite remaining space they would otherwise be forced to take, and then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum constraints provided by the parent.
If this message did not help you determine the problem, consider using debugDumpRenderTree():
https://flutter.dev/debugging/#rendering-layer
http://api.flutter.dev/flutter/rendering/debugDumpRenderTree.html
The affected RenderFlex is: RenderFlex#bf474 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none> (can use size)
constraints: BoxConstraints(w=360.0, 0.0<=h<=Infinity)
size: MISSING
direction: vertical
mainAxisAlignment: start
mainAxisSize: max
crossAxisAlignment: center
verticalDirection: down
... child 1: RenderRepaintBoundary#1afda NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
... constraints: MISSING
... size: MISSING
... usefulness ratio: no metrics collected yet (never painted)
... child: RenderCustomPaint#35c8e NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData: <none>
... constraints: MISSING
... size: MISSING
... child: RenderRepaintBoundary#91327 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: <none>
... constraints: MISSING
... size: MISSING
... usefulness ratio: no metrics collected yet (never painted)
... child: _RenderScrollSemantics#85e9b NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData: <none>
... constraints: MISSING
... semantic boundary
... size: MISSING
... child 2: RenderRepaintBoundary#94ff7 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
... constraints: MISSING
... size: MISSING
... usefulness ratio: no metrics collected yet (never painted)
... child: RenderCustomPaint#064c6 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData: <none>
... constraints: MISSING
... size: MISSING
... child: RenderRepaintBoundary#032ad NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: <none>
... constraints: MISSING
... size: MISSING
... usefulness ratio: no metrics collected yet (never painted)
... child: _RenderScrollSemantics#2473a NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData: <none>
... constraints: MISSING
... semantic boundary
... size: MISSING
The creator information is set to: Column ← _SingleChildViewport ← IgnorePointer-[GlobalKey#a96e8] ← Semantics ← _PointerListener ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#2d1ee] ← _PointerListener ← Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#be83e] ← ⋯
The nearest ancestor providing an unbounded width constraint is: _RenderSingleChildViewport#7d98f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(w=360.0, h=471.0)
... size: MISSING
See also: https://flutter.dev/layout/
If none of the above helps enough to fix this problem, please don't hesitate to file a bug:
https://github.com/flutter/flutter/issues/new?template=BUG.md
The relevant error-causing widget was:
Column file:///D:/Other/App/Flutter/flash/lib/main_screens/tabs/today_tab.dart:12:14
When the exception was thrown, this was the stack:
#0 RenderFlex.performLayout.<anonymous closure> (package:flutter/src/rendering/flex.dart:712:11)
#1 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:739:10)
#2 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
#3 _RenderSingleChildViewport.performLayout (package:flutter/src/widgets/single_child_scroll_view.dart:544:13)
#4 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
...
The following RenderObject was being processed when the exception was fired: RenderFlex#bf474 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData: <none> (can use size)
... constraints: BoxConstraints(w=360.0, 0.0<=h<=Infinity)
... size: MISSING
... direction: vertical
... mainAxisAlignment: start
... mainAxisSize: max
... crossAxisAlignment: center
... verticalDirection: down
RenderObject: RenderFlex#bf474 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
parentData: <none> (can use size)
constraints: BoxConstraints(w=360.0, 0.0<=h<=Infinity)
size: MISSING
direction: vertical
mainAxisAlignment: start
mainAxisSize: max
crossAxisAlignment: center
verticalDirection: down
... child 1: RenderRepaintBoundary#1afda NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
... constraints: MISSING
... size: MISSING
... usefulness ratio: no metrics collected yet (never painted)
... child: RenderCustomPaint#35c8e NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData: <none>
... constraints: MISSING
... size: MISSING
... child: RenderRepaintBoundary#91327 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: <none>
... constraints: MISSING
... size: MISSING
... usefulness ratio: no metrics collected yet (never painted)
... child: _RenderScrollSemantics#85e9b NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData: <none>
... constraints: MISSING
... semantic boundary
... size: MISSING
... child 2: RenderRepaintBoundary#94ff7 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
... constraints: MISSING
... size: MISSING
... usefulness ratio: no metrics collected yet (never painted)
... child: RenderCustomPaint#064c6 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData: <none>
... constraints: MISSING
... size: MISSING
... child: RenderRepaintBoundary#032ad NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: <none>
... constraints: MISSING
... size: MISSING
... usefulness ratio: no metrics collected yet (never painted)
... child: _RenderScrollSemantics#2473a NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData: <none>
... constraints: MISSING
... semantic boundary
... size: MISSING
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: RenderBox was not laid out: RenderPointerListener#dd9af NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#e7712 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
RenderBox was not laid out: RenderFlex#bf474 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1702 pos 12: 'hasSize'
The relevant error-causing widget was:
SingleChildScrollView file:///D:/Other/App/Flutter/flash/lib/main_screens/tabs/today_tab.dart:11:12
Это мой класс
class Today extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [
Expanded(
child: ListView1(),
),
Expanded(
child: ListView2(),
),
],
),
);
}
}
Это мои ListView1 и ListView2 …. оба класса одинаковы для лучшего понимания.
class ListView1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: classData.length,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
return ClassListTile(
startTime: classData[index].startTime,
endTime: classData[index].endTime,
subName: classData[index].subName,
subCode: classData[index].subCode,
staffName: classData[index].staffName,
isPresent: classData[index].isPresent,
);
});
}
}
Ответ №1:
Удалите Expanded
виджеты. Они пытаются занять как можно больше места в своем родительском элементе, который в данном случае бесконечен из-за родительского Column
элемента, обернутого SingleChildScrollView
.
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [
ListView1(),
ListView2(),
],
),
);
}
Комментарии:
1. Это не позволит конструктору элементов создавать элементы по требованию. Все элементы в listview создаются одновременно. Есть ли решение для этого?
2. Да, есть какой-то способ с использованием
CustomScrollView
andSliverList
.