我的代码有问题,我不知道发生了什么,因为没有任何东西亮起。 当我重新加载代码并单击屏幕上的某些内容时,我的终端会显示:
> ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during performResize():
Vertical viewport was given unbounded height.
Viewports expand in the scrolling direction to fill their container. In this case, a vertical
viewport was given an unlimited amount of vertical space in which to expand. This situation
typically happens when a scrollable widget is nested inside another scrollable widget.
If this widget is always nested in a scrollable widget there is no need to use a viewport because
there will always be enough vertical space for the children. In this case, consider using a Column
instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
the height of the viewport to the sum of the heights of its children.
The relevant error-causing widget was:
ListView
file:///Users/dominikkolber/Desktop/algotrading/worked_project/lib/widgets/transactions_list.dart:15:25
When the exception was thrown, this was the stack:
#0 RenderViewport.computeDryLayout.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1365:15)
#1 RenderViewport.computeDryLayout (package:flutter/src/rendering/viewport.dart:1426:6)
#2 RenderBox.performResize (package:flutter/src/rendering/box.dart:2342:12)
#3 RenderObject.layout (package:flutter/src/rendering/object.dart:1763:9)
#4 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#5 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#6 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#7 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#8 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#9 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#10 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#11 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#12 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#13 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#14 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#15 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#16 RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:279:14)
#17 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#18 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:54:11)
#19 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:897:45)
#20 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:932:32)
#21 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#22 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:54:11)
#23 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:830:43)
#24 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:932:32)
#25 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#26 _RenderSingleChildViewport.performLayout (package:flutter/src/widgets/single_child_scroll_view.dart:558:14)
#27 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#28 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#29 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#30 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#31 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#32 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#33 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#34 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#35 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#36 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#37 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#38 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#39 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#40 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:171:12)
#41 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:925:7)
#42 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:243:7)
#43 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:407:14)
#44 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#45 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#46 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#47 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#48 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1371:11)
#49 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#50 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#51 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#52 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#53 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#54 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#55 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#56 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:54:11)
#57 RenderStack._computeSize (package:flutter/src/rendering/stack.dart:570:43)
#58 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:597:12)
#59 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#60 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#61 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#62 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#63 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#64 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#65 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#66 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#67 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#68 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#69 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#70 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#71 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3362:13)
#72 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#73 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#74 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#75 _RenderTheatre.performLayout (package:flutter/src/widgets/overlay.dart:743:15)
#76 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#77 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#78 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#79 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#80 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#81 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#82 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#83 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#84 RenderCustomPaint.performLayout (package:flutter/src/rendering/custom_paint.dart:546:11)
#85 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#86 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#87 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#88 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:118:14)
#89 RenderObject.layout (package:flutter/src/rendering/object.dart:1784:7)
#90 RenderView.performLayout (package:flutter/src/rendering/view.dart:153:14)
#91 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1641:7)
#92 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:884:18)
#93 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:453:19)
#94 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:874:13)
#95 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:319:5)
#96 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
#97 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1082:9)
#98 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:865:7)
(elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
The following RenderObject was being processed when the exception was fired: RenderViewport#cbc71 NEEDS-LAYOUT
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
needs compositing
creator: Viewport ← IgnorePointer-[GlobalKey#28017] ← Semantics ← Listener ← _GestureSemantics ←
RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#e8dad] ← Listener ← _ScrollableScope
← _ScrollSemantics-[GlobalKey#d4bfb] ← Scrollable ← ListView ← ConstrainedBox ← ⋯
parentData: <none> (can use size)
constraints: BoxConstraints(w=300.0, 0.0<=h<=Infinity)
size: MISSING
axisDirection: down
crossAxisDirection: right
offset: ScrollPositionWithSingleContext#a246f(offset: 0.0, range: null..null, viewport: null,
ScrollableState, AlwaysScrollableScrollPhysics -> BouncingScrollPhysics ->
RangeMaintainingScrollPhysics, IdleScrollActivity#b67a4, ScrollDirection.idle)
anchor: 0.0
This RenderObject had the following descendants (showing up to depth 5):
center child: RenderSliverPadding#ab96d NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderSliverList#474d3 NEEDS-LAYOUT NEEDS-PAINT
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: RenderBox was not laid out: RenderViewport#cbc71 NEEDS-LAYOUT NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderViewport#cbc71 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#14767 relayoutBoundary=up16 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#8657d relayoutBoundary=up15
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderPointerListener#b5a18 relayoutBoundary=up14 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#fffbd relayoutBoundary=up13
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderPointerListener#12b1c relayoutBoundary=up12 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#59657 relayoutBoundary=up11 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderConstrainedBox#69ea6 relayoutBoundary=up10 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderFlex#0e0b0 relayoutBoundary=up9 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderFlex#a112f relayoutBoundary=up8 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: _RenderSingleChildViewport#45682 relayoutBoundary=up7
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#8bbd3 relayoutBoundary=up6 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#617d0 relayoutBoundary=up5
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderPointerListener#dffcd relayoutBoundary=up4 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#66524 relayoutBoundary=up3
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: RenderPointerListener#5238d relayoutBoundary=up2 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#01cd6 relayoutBoundary=up1 NEEDS-PAINT
NEEDS-COMPOSITING-BITS-UPDATE
Another exception was thrown: RenderBox was not laid out: _RenderSingleChildViewport#45682 relayoutBoundary=up7
NEEDS-PAINT
Another exception was thrown: Null check operator used on a null value
Another exception was thrown: Bad state: Future already completed
[VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: 'package:flutter/src/rendering/box.dart': Failed assertion: line 1940 pos 12: 'hasSize': RenderBox was not laid out: RenderPointerListener#14f8e NEEDS-LAYOUT NEEDS-PAINT
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
#2 RenderBox.size (package:flutter/src/rendering/box.dart:1940:12)
#3 RenderProxyBoxWithHitTestBehavior.hitTest (package:flutter/src/rendering/proxy_box.dart:179:9)
#4 RenderBoxContainerDefaultsMixin.defaultHitTestChildren.<anonymous closure> (package:flutter/src/rendering/box.dart:2785:25)
#5 BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:787:31)
#6 RenderBoxContainerDefaultsMixin.defaultHitTestChildren (package:flutter/src/rendering/box.dart:2780:33)
#7 RenderCustomMultiChildLayoutBox.hitTestChildren (package:flutter/src/rendering/custom_layout.dart:417:12)
#8 Rend<…>
[VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: 'package:flutter/src/rendering/box.dart': Failed assertion: line 1940 pos 12: 'hasSize': RenderBox was not laid out: RenderPointerListener#14f8e NEEDS-LAYOUT NEEDS-PAINT
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
#2 RenderBox.size (package:flutter/src/rendering/box.dart:1940:12)
#3 RenderProxyBoxWithHitTestBehavior.hitTest (package:flutter/src/rendering/proxy_box.dart:179:9)
#4 RenderBoxContainerDefaultsMixin.defaultHitTestChildren.<anonymous closure> (package:flutter/src/rendering/box.dart:2785:25)
#5 BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:787:31)
#6 RenderBoxContainerDefaultsMixin.defaultHitTestChildren (package:flutter/src/rendering/box.dart:2780:33)
#7 RenderCustomMultiChildLayoutBox.hitTestChildren (package:flutter/src/rendering/custom_layout.dart:417:12)
#8 Rend<…>
我真的不知道我在看教程时有什么问题,如果有人想帮忙,下面是我的代码
https://gist.github.com/agentkolby/313a65939eb4a8e0a136f5fa7bc36925
答案 0 :(得分:0)
请在下面尝试。更改 user_transactions.dart 中的代码
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: <Widget>[
NewTransaction(_addNewTransaction),
TransactionList(_userTransactions),
],
),
);
}
您不能在 Expanded
中使用 Column
。