How to use Expanded in stepper when using columns - dart

Here is a relatable stack overflow question .
Flutter : Step widget can not hold Expanded
If one reads the comments #derek-lakin, concludes that one should use a column inside a stepper, as stepper is scrollable. I am doing the exact same thing, however i face an issue that column makes the Text widget to take only the required space, and not the entire screen width. I can notice this if i wrap the Text widget with a Material widget and apply elevation or color.
I tried to wrap Expanded widget around my Column of widgets to fix this. However, i get render errors.
Can someone let me know, how can I build a stepper, with a step that consists of hierarchy as Expanded(Column(children:List[Widgets])).
I am able to build a stepper using only column, but i was thinking of using expanded to correct the inappropriate sizing issues in column
stepWidget = Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: widgets, //List of my widgets
));
This gives the following error:
I/flutter (19635): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (19635): The following assertion was thrown building NotificationListener<KeepAliveNotification>:
I/flutter (19635): Incorrect use of ParentDataWidget.
I/flutter (19635): Expanded widgets must be placed directly inside Flex widgets.
I/flutter (19635): Expanded(no depth, flex: 2, dirty) has a Flex ancestor, but there are other widgets between them:
I/flutter (19635): - RepaintBoundary-[<0>]
I/flutter (19635): - IndexedSemantics(index: 0)
I/flutter (19635): - KeepAlive(keepAlive: false)
I/flutter (19635): - SliverList(delegate: SliverChildListDelegate#de272(estimated child count: 1))
I/flutter (19635): - SliverPadding(padding: EdgeInsets.zero)
I/flutter (19635): - ShrinkWrappingViewport(axisDirection: down, offset: ScrollPositionWithSingleContext#83fdf(offset:
I/flutter (19635): 0.0, range: null..null, viewport: null, ScrollableState, ClampingScrollPhysics,
I/flutter (19635): IdleScrollActivity#b00f3, ScrollDirection.idle))
I/flutter (19635): - IgnorePointer-[GlobalKey#88af5](ignoring: false, ignoringSemantics: false)
I/flutter (19635): - Semantics(container: false, properties: SemanticsProperties, label: null, value: null, hint: null,
I/flutter (19635): hintOverrides: null)
I/flutter (19635): - Listener(listeners: [down], behavior: opaque)
I/flutter (19635): - _GestureSemantics
I/flutter (19635): - _ScrollSemantics-[GlobalKey#81c78]
I/flutter (19635): - RepaintBoundary
I/flutter (19635): - CustomPaint
I/flutter (19635): - RepaintBoundary
I/flutter (19635): - Expanded(flex: 1) (this is a different Expanded than the one with the problem)
I/flutter (19635): These widgets cannot come between a Expanded and its Flex.
I/flutter (19635): The ownership chain for the parent of the offending Expanded was:
I/flutter (19635): RepaintBoundary-[<0>] ← IndexedSemantics ← NotificationListener<KeepAliveNotification> ← KeepAlive
I/flutter (19635): ← AutomaticKeepAlive ← SliverList ← MediaQuery ← SliverPadding ← ShrinkWrappingViewport ←
I/flutter (19635): _ScrollableScope ← ⋯
I/flutter (19635):
I/flutter (19635): When the exception was thrown, this was the stack:
I/flutter (19635): #0 ParentDataElement.mount.<anonymous closure> (package:flutter/src/widgets/framework.dart:4015:7)
I/flutter (19635): #1 ParentDataElement.mount (package:flutter/src/widgets/framework.dart:4024:6)
I/flutter (19635): #2 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (19635): #3 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (19635): #4 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4838:14)
I/flutter (19635): #5 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (19635): #6 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (19635): #7 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4838:14)
I/flutter (19635): #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (19635): #9 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (19635): #10 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3710:16)
I/flutter (19635): #11 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (19635): #12 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3679:5)
I/flutter (19635): #13 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3674:5)
I/flutter (19635): #14 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (19635): #15 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (19635): #16 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3710:16)
I/flutter (19635): #17 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (19635): #18 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3679:5)
I/flutter (19635): #19 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3674:5)
I/flutter (19635): #20 ParentDataElement.mount (package:flutter/src/widgets/framework.dart:4025:11)
I/flutter (19635): #21 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (19635): #22 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (19635): #23 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3710:16)
I/flutter (19635): #24 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (19635): #25 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3679:5)
I/flutter (19635): #26 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3826:11)
I/flutter (19635): #27 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3674:5)
I/flutter (19635): #28 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (19635): #29 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (19635): #30 SliverMultiBoxAdaptorElement.updateChild (package:flutter/src/widgets/sliver.dart:1012:36)
I/flutter (19635): #31 SliverMultiBoxAdaptorElement.createChild.<anonymous closure> (package:flutter/src/widgets/sliver.dart:997:20)
I/flutter (19635): #32 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2266:19)
I/flutter (19635): #33 SliverMultiBoxAdaptorElement.createChild (package:flutter/src/widgets/sliver.dart:990:11)
I/flutter (19635): #34 RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure> (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:256:23)
I/flutter (19635): #35 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1730:58)
I/flutter (19635): #36 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:799:15)
I/flutter (19635): #37 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1730:13)
I/flutter (19635): #38 RenderSliverMultiBoxAdaptor._createOrObtainChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:245:5)
I/flutter (19635): #39 RenderSliverMultiBoxAdaptor.addInitialChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:323:5)
I/flutter (19635): #40 RenderSliverList.performLayout (package:flutter/src/rendering/sliver_list.dart:78:12)
I/flutter (19635): #41 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #42 RenderSliverPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:182:11)
I/flutter (19635): #43 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #44 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:405:13)
I/flutter (19635): #45 RenderShrinkWrappingViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1645:12)
I/flutter (19635): #46 RenderShrinkWrappingViewport.performLayout (package:flutter/src/rendering/viewport.dart:1608:20)
I/flutter (19635): #47 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #48 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #49 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #50 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #51 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #52 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #53 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #54 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #55 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #56 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #57 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #58 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #59 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #60 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #61 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #62 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19635): #63 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #64 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:798:17)
I/flutter (19635): #65 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19635): #66 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11)
I/flutter (19635): #67 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:339:7)
I/flutter (19635): #68 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7)
I/flutter (19635): #69 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14)
I/flutter (19635): #70 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
I/flutter (19635): #71 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
I/flutter (19635): #72 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
I/flutter (19635): #73 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:677:13)
I/flutter (19635): #74 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter (19635): #75 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (19635): #76 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (19635): #77 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter (19635): #78 _invoke (dart:ui/hooks.dart:151:13)
I/flutter (19635): #79 _drawFrame (dart:ui/hooks.dart:140:3)
I/flutter (19635): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (19635): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 217 pos 16: 'indexOf(child) > index': is not true.
I/flutter (19635): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 217 pos 16: 'indexOf(child) > index': is not true.
I/flutter (19635): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 2270 pos 20: '_debugCurrentBuildTarget == context': is not true.
I/flutter (19635): Another exception was thrown: NoSuchMethodError: The getter 'scrollOffsetCorrection' was called on null.
I/flutter (19635): Another exception was thrown: NoSuchMethodError: The method 'debugAssertIsValid' was called on null.
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderShrinkWrappingViewport#44117 relayoutBoundary=up10 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#7c8dd relayoutBoundary=up9 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#f736b relayoutBoundary=up8 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderPointerListener#3760f relayoutBoundary=up7 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#860e2 relayoutBoundary=up6 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#b1734 relayoutBoundary=up5 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#d9292 relayoutBoundary=up4 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#44461 relayoutBoundary=up3 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#4425c relayoutBoundary=up2 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: RenderBox was not laid out: RenderFlex#e5d03 relayoutBoundary=up1 NEEDS-PAINT
I/flutter (19635): Another exception was thrown: NoSuchMethodError: The method '<=' was called on null.

As per the error: Expanded widgets must be placed directly inside Flex widgets.
Why?
As per docs:
An Expanded widget must be a descendant of a Row, Column, or Flex, and the path from the Expanded widget to its enclosing Row, Column, or Flex must contain only StatelessWidgets or StatefulWidgets (not other kinds of widgets, like RenderObjectWidgets).
You can place Expanded widget inside Column and put that Column inside your Step widget, but you can not place Expanded directly inside your Step widget's content.
I'll update my answer once you'll provide the full code to provide you with the solution.
Till then, here's what you can do.
Container(
width: double.infinity, //To make it use as much space as it wants
height: whateverHeightYouWantTo,
child: Column(
children: <Widget>[
Expanded(child: Widget()) //You'll probably won't need Expanded by now.
]
)
)

Related

Flutter exception 'package:flutter/src/widgets/sliver.dart': Failed assertion 'child != null' is not true

I'm getting this Exception from flutter package sliver.dart, when I navigate to a new page.
All of this was working fine, but later I tried to add multiple features to it like connecting sqlite database, I thought that would be the problem So I tried to go back to the last working state of my app by removing every additional code. But unfortunately it's still giving me this error. Even if you look at my frontend code below there is nothing special right now it's just displaying data that I already have in an object.
Tried completely reinstalling the app but no solution still.
Running "flutter packages get" in heron... 1.5s
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Built build\app\outputs\apk\debug\app-debug.apk.
D/ (23206): HostConnection::get() New Host Connection established 0xa4b249c0, tid 23228
D/EGL_emulation(23206): eglMakeCurrent: 0xa6594cc0: ver 3 0 (tinfo 0x94a360d0)
I/flutter (23206): TV GET Requested
I/flutter (23206): Movie GET Requested
I/flutter (23206): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (23206): The following assertion was thrown during performLayout():
I/flutter (23206): 'package:flutter/src/widgets/sliver.dart': Failed assertion: line 553 pos 12: 'child != null': is
I/flutter (23206): not true.
I/flutter (23206):
I/flutter (23206): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (23206): more information in this error message to help you determine and fix the underlying cause.
I/flutter (23206): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (23206): https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter (23206):
I/flutter (23206): When the exception was thrown, this was the stack:
I/flutter (23206): #2 SliverChildListDelegate.build
I/flutter (23206): #3 SliverMultiBoxAdaptorElement._build.<anonymous closure>
I/flutter (23206): #4 _HashMap.putIfAbsent (dart:collection/runtime/libcollection_patch.dart:137:29)
I/flutter (23206): #5 SliverMultiBoxAdaptorElement._build
I/flutter (23206): #6 SliverMultiBoxAdaptorElement.createChild.<anonymous closure>
I/flutter (23206): #7 BuildOwner.buildScope
I/flutter (23206): #8 SliverMultiBoxAdaptorElement.createChild
I/flutter (23206): #9 RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure>
I/flutter (23206): #10 RenderObject.invokeLayoutCallback.<anonymous closure>
I/flutter (23206): #11 PipelineOwner._enableMutationsToDirtySubtrees
I/flutter (23206): #12 RenderObject.invokeLayoutCallback
I/flutter (23206): #13 RenderSliverMultiBoxAdaptor._createOrObtainChild
I/flutter (23206): #14 RenderSliverMultiBoxAdaptor.insertAndLayoutChild
I/flutter (23206): #15 RenderSliverList.performLayout.advance
I/flutter (23206): #16 RenderSliverList.performLayout
I/flutter (23206): #17 RenderObject.layout
I/flutter (23206): #18 RenderSliverPadding.performLayout
I/flutter (23206): #19 RenderObject.layout
I/flutter (23206): #20 RenderViewportBase.layoutChildSequence
I/flutter (23206): #21 RenderViewport._attemptLayout
I/flutter (23206): #22 RenderViewport.performLayout
I/flutter (23206): #23 RenderObject.layout
I/flutter (23206): #24 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #25 RenderObject.layout
I/flutter (23206): #26 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #27 RenderObject.layout
I/flutter (23206): #28 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #29 RenderObject.layout
I/flutter (23206): #30 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #31 RenderObject.layout
I/flutter (23206): #32 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #33 RenderObject.layout
I/flutter (23206): #34 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #35 RenderObject.layout
I/flutter (23206): #36 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #37 RenderObject.layout
I/flutter (23206): #38 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #39 RenderObject.layout
I/flutter (23206): #40 RenderPadding.performLayout
I/flutter (23206): #41 RenderObject.layout
I/flutter (23206): #42 MultiChildLayoutDelegate.layoutChild
I/flutter (23206): #43 _ScaffoldLayout.performLayout
I/flutter (23206): #44 MultiChildLayoutDelegate._callPerformLayout
I/flutter (23206): #45 RenderCustomMultiChildLayoutBox.performLayout
I/flutter (23206): #46 RenderObject.layout
I/flutter (23206): #47 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #48 RenderObject.layout
I/flutter (23206): #49 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #50 _RenderCustomClip.performLayout
I/flutter (23206): #51 RenderObject.layout
I/flutter (23206): #52 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #53 RenderObject.layout
I/flutter (23206): #54 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #55 RenderObject.layout
I/flutter (23206): #56 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #57 RenderObject.layout
I/flutter (23206): #58 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #59 RenderObject.layout
I/flutter (23206): #60 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #61 RenderObject.layout
I/flutter (23206): #62 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #63 RenderObject.layout
I/flutter (23206): #64 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout
I/flutter (23206): #65 RenderObject.layout
I/flutter (23206): #66 RenderOffstage.performLayout
I/flutter (23206): #67 RenderObject.layout
I/flutter (23206): #68 RenderStack.performLayout
I/flutter (23206): #69 RenderObject._layoutWithoutResize
I/flutter (23206): #70 PipelineOwner.flushLayout
I/flutter (23206): #71 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame
I/flutter (23206): #72 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame
I/flutter (23206): #73 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback
I/flutter (23206): #74 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback
I/flutter (23206): #75 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame
I/flutter (23206): #76 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame
I/flutter (23206): #80 _invoke (dart:ui/hooks.dart:209:10)
I/flutter (23206): #81 _drawFrame (dart:ui/hooks.dart:168:3)
I/flutter (23206): (elided 5 frames from class _AssertionError and package dart:async)
I/flutter (23206):
I/flutter (23206): The following RenderObject was being processed when the exception was fired:
I/flutter (23206): RenderSliverList#19980 relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (23206): creator: SliverList ← MediaQuery ← SliverPadding ← Viewport ← IgnorePointer-[GlobalKey#7290e] ←
I/flutter (23206): Semantics ← Listener ← _GestureSemantics ←
I/flutter (23206): RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#9ea0f] ← _ScrollableScope ←
I/flutter (23206): _ScrollSemantics-[GlobalKey#aa43f] ← RepaintBoundary ← ⋯
I/flutter (23206): parentData: paintOffset=Offset(0.0, 0.0) (can use size)
I/flutter (23206): constraints: SliverConstraints(AxisDirection.down, GrowthDirection.forward, ScrollDirection.idle,
I/flutter (23206): scrollOffset: 0.0, remainingPaintExtent: 598.4, crossAxisExtent: 381.4, crossAxisDirection:
I/flutter (23206): AxisDirection.right, viewportMainAxisExtent: 598.4, remainingCacheExtent: 848.4 cacheOrigin: 0.0 )
I/flutter (23206): geometry: null
I/flutter (23206): currently live children: 0 to 2
I/flutter (23206): This RenderObject had the following descendants (showing up to depth 5):
I/flutter (23206): RenderIndexedSemantics#6d89b relayoutBoundary=up3 NEEDS-PAINT
I/flutter (23206): RenderRepaintBoundary#41a15 relayoutBoundary=up4 NEEDS-PAINT
I/flutter (23206): RenderConstrainedBox#f6331 relayoutBoundary=up5 NEEDS-PAINT
I/flutter (23206): RenderStack#1d492 NEEDS-PAINT
I/flutter (23206): RenderSemanticsAnnotations#dee5b relayoutBoundary=up1 NEEDS-PAINT
I/flutter (23206): RenderSemanticsAnnotations#75402 NEEDS-PAINT
I/flutter (23206): RenderConstrainedBox#553a7 relayoutBoundary=up1 NEEDS-PAINT
I/flutter (23206): RenderIndexedSemantics#dbd86 relayoutBoundary=up3 NEEDS-PAINT
I/flutter (23206): RenderRepaintBoundary#d9292 relayoutBoundary=up4 NEEDS-PAINT
I/flutter (23206): RenderDecoratedBox#fdc4c relayoutBoundary=up5 NEEDS-PAINT
I/flutter (23206): RenderSemanticsGestureHandler#fac22 relayoutBoundary=up6 NEEDS-PAINT
I/flutter (23206): RenderPointerListener#bca58 relayoutBoundary=up7 NEEDS-PAINT
I/flutter (23206): RenderIndexedSemantics#dc7c8 relayoutBoundary=up3 NEEDS-PAINT
I/flutter (23206): RenderRepaintBoundary#f0361 relayoutBoundary=up4 NEEDS-PAINT
I/flutter (23206): RenderSemanticsGestureHandler#29897 relayoutBoundary=up5 NEEDS-PAINT
I/flutter (23206): RenderPointerListener#e3417 relayoutBoundary=up6 NEEDS-PAINT
I/flutter (23206): RenderSemanticsAnnotations#69a6f relayoutBoundary=up7 NEEDS-PAINT
I/flutter (23206): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (23206): Another exception was thrown: NoSuchMethodError: The getter 'scrollOffsetCorrection' was called on null.
I/flutter (23206): Another exception was thrown: NoSuchMethodError: The method 'debugAssertIsValid' was called on null.
I/flutter (23206): Another exception was thrown: NoSuchMethodError: The getter 'visible' was called on null.
I have divided my code into two pages
front end - https://gist.github.com/purplecandy/54234b2080f27b43075ef289489ecf5b
functions - https://gist.github.com/purplecandy/8d7a8cb0e3e001d6517ddc21dde72256
pubspec - https://gist.github.com/purplecandy/06be5d9a521239052a25cbe6e042471b
Can anyone give me some insight what is causing this issue? Where am I wrong? Or just explain the error to me
Base from the logs, the expected child of the Widget seems to be null. If you're still having issues, sharing code snippets of the line causing the error should help us understand the issue.

Flutter - exception after adding list of Cards and Text on the same page

I want to display a Text (or another type of Content) and a list of Cards. I am able to display only the list of Cards but it throws an exception if I add another class.
Code for only the list of Cards (it works):
class CardPageState extends State<CardPage> {
//DeckCard is a class which contains title, description, etc
final decks = <DeckCard>[];
CardPageState(data){
decks.addAll(data);
}
#override
Widget build(BuildContext context) {
return Container(
child: buildCardPage(),
);
}
Widget buildCardPage() {
return new Container(
child: new ListView.builder(
itemCount: decks.length,
itemBuilder: /*1*/ (context, i) {
return _buildRow(decks[i]);
})
);
}
Widget _buildRow(DeckCard deckCard) {
return new Card(
child: Text(deckCard.getTitle(), style: TextStyle(fontWeight: FontWeight.bold,fontSize: 20, color:Colors.black),)
);
}
}
CardPage is called from a main page with a body:
body: new Container(
child: new FutureBuilder<DeckCardResponse>(
future: fetchDecksFromFirebase(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return new CardPage(snapshot.data.getDecks());
}
else if (snapshot.hasError) {
return new MessageError(499);
}
return new CircularProgressIndicator(strokeWidth: 5.0);
}),
)
When I try to add another content and it throws an exception:
Widget buildCardPage() {
return new Container(
child:
new Column(
children:[
new Text("hello", style: TextStyle(fontWeight: FontWeight.bold,fontSize: 20, color:Colors.black),),
new Container(
child: new ListView.builder(
itemCount: decks.length,
itemBuilder: /*1*/ (context, i) {
return _buildRow(decks[i]);
})
),
]
),
);
Any idea? I tried with only a Column without the previous Container, however, I have the same exception.
I/flutter (18134): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (18134): The following assertion was thrown during performResize():
I/flutter (18134): Vertical viewport was given unbounded height.
I/flutter (18134): Viewports expand in the scrolling direction to fill their container.In this case, a vertical
I/flutter (18134): viewport was given an unlimited amount of vertical space in which to expand. This situation
I/flutter (18134): typically happens when a scrollable widget is nested inside another scrollable widget.
I/flutter (18134): If this widget is always nested in a scrollable widget there is no need to use a viewport because
I/flutter (18134): there will always be enough vertical space for the children. In this case, consider using a Column
I/flutter (18134): instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
I/flutter (18134): the height of the viewport to the sum of the heights of its children.
I/flutter (18134):
I/flutter (18134): When the exception was thrown, this was the stack:
I/flutter (18134): #0 RenderViewport.performResize.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1135:15)
I/flutter (18134): #1 RenderViewport.performResize (package:flutter/src/rendering/viewport.dart:1188:6)
I/flutter (18134): #2 RenderObject.layout (package:flutter/src/rendering/object.dart:1617:9)
I/flutter (18134): #3 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #4 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #5 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #6 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #7 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #8 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #9 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #10 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #11 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #12 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #13 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #14 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #15 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #16 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #17 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #18 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #19 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:738:15)
I/flutter (18134): #20 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #21 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11)
I/flutter (18134): #22 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:350:7)
I/flutter (18134): #23 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7)
I/flutter (18134): #24 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14)
I/flutter (18134): #25 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #26 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #27 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #28 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #29 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1206:11)
I/flutter (18134): #30 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #31 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #32 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #33 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #34 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #35 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #36 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #37 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #38 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #39 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #40 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #41 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #42 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #43 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #44 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #45 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #46 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3032:13)
I/flutter (18134): #47 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #48 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
I/flutter (18134): #49 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #50 __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #51 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #52 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #53 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #54 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #55 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #56 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #57 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #58 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #59 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #60 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (18134): #61 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (18134): #62 RenderView.performLayout (package:flutter/src/rendering/view.dart:151:13)
I/flutter (18134): #63 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1507:7)
I/flutter (18134): #64 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:766:18)
I/flutter (18134): #65 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:329:19)
I/flutter (18134): #66 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:701:13)
I/flutter (18134): #67 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:268:5)
I/flutter (18134): #68 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:988:15)
I/flutter (18134): #69 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:928:9)
I/flutter (18134): #70 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:749:7)
I/flutter (18134): #72 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
I/flutter (18134): #73 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
I/flutter (18134): #74 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter (18134): (elided one frame from package dart:async)
I/flutter (18134):
I/flutter (18134): The following RenderObject was being processed when the exception was fired:
I/flutter (18134): RenderViewport#85bc5 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (18134): creator: Viewport ← IgnorePointer-[GlobalKey#ddac3] ← Semantics ← Listener ← _GestureSemantics ←
I/flutter (18134): RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#142b9] ← _ScrollableScope ←
I/flutter (18134): _ScrollSemantics-[GlobalKey#1902d] ← RepaintBoundary ← CustomPaint ← RepaintBoundary ←
I/flutter (18134): NotificationListener<ScrollNotification> ← ⋯
I/flutter (18134): parentData: <none> (can use size)
I/flutter (18134): constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=Infinity)
I/flutter (18134): size: MISSING
I/flutter (18134): axisDirection: down
I/flutter (18134): crossAxisDirection: right
I/flutter (18134): offset: ScrollPositionWithSingleContext#06797(offset: 0.0, range: null..null, viewport: null,
I/flutter (18134): ScrollableState, AlwaysScrollableScrollPhysics -> ClampingScrollPhysics, IdleScrollActivity#c3663,
I/flutter (18134): ScrollDirection.idle)
I/flutter (18134): anchor: 0.0
I/flutter (18134): This RenderObject had the following descendants (showing up to depth 5):
I/flutter (18134): RenderSliverPadding#e7182 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (18134): RenderSliverList#6b5c0 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (18134): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (18134): Another exception was thrown: RenderBox was not laid out: RenderViewport#85bc5 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (18134): Another exception was thrown: RenderBox was not laid out: RenderViewport#85bc5 NEEDS-PAINT
I/flutter (18134): Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#c5ace relayoutBoundary=up9 NEEDS-PAINT
I/flutter (18134): Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#f4095 relayoutBoundary=up8 NEEDS-PAINT
I/flutter (18134): Another exception was thrown: RenderBox was not laid out: RenderPointerListener#1d571 relayoutBoundary=up7 NEEDS-PAINT
I/flutter (18134): Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#5cee1 relayoutBoundary=up6 NEEDS-PAINT
I/flutter (18134): Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#1f2eb relayoutBoundary=up5 NEEDS-PAINT
I/flutter (18134): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#70e3d relayoutBoundary=up4 NEEDS-PAINT
I/flutter (18134): Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#b103f relayoutBoundary=up3 NEEDS-PAINT
I/flutter (18134): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#4b75f relayoutBoundary=up2 NEEDS-PAINT
I/flutter (18134): Another exception was thrown: RenderBox was not laid out: RenderFlex#aaf3d relayoutBoundary=up1 NEEDS-PAINT
I/flutter (18134): Another exception was thrown: NoSuchMethodError: The method '<=' was called on null.
Reloaded 2 of 573 libraries in 1,622ms.
You have to give the parent Container a height as listview and Column widgets expands to match the height of their parent, which is in your case the Container.Try giving it the screen height using MediaQuery if you don't have any certain size in mind:
body: new Container(
height: MediaQuery.of(context).size.height, // This will make the size of it the same as the device screen
child: new FutureBuilder<DeckCardResponse>(
future: fetchDecksFromFirebase(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return new CardPage(snapshot.data.getDecks());
}
else if (snapshot.hasError) {
return new MessageError(499);
}
return new CircularProgressIndicator(strokeWidth: 5.0);
}),
)

Positioned Widget Causes Child To Disappear/Exception

I am currently learning Flutter and I am trying to position a carousel at the bottom of the screen using the Positioned widget in a Stack. Currently, the stack is a map, with the carousel on top of that. When I use the positioned widget to move the carousel to the bottom it disappears and I am met with this error.
I/flutter (19228): Another exception was thrown: 'package:flutter/src/rendering/object.dart': Failed assertion: line 1578 pos 12: '!_debugDoingThisLayout': is not true.
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#51ed3 relayoutBoundary=up4 NEEDS-LAYOUT NEEDS-PAINT
Restarted application in 1,970ms.
I/flutter (19228): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (19228): The following assertion was thrown during performResize():
I/flutter (19228): Horizontal viewport was given unbounded width.
I/flutter (19228): Viewports expand in the scrolling direction to fill their container.In this case, a horizontal
I/flutter (19228): viewport was given an unlimited amount of horizontal space in which to expand. This situation
I/flutter (19228): typically happens when a scrollable widget is nested inside another scrollable widget.
I/flutter (19228): If this widget is always nested in a scrollable widget there is no need to use a viewport because
I/flutter (19228): there will always be enough horizontal space for the children. In this case, consider using a Row
I/flutter (19228): instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
I/flutter (19228): the width of the viewport to the sum of the widths of its children.
I/flutter (19228):
I/flutter (19228): When the exception was thrown, this was the stack:
I/flutter (19228): #0 RenderViewport.performResize.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1155:15)
I/flutter (19228): #1 RenderViewport.performResize (package:flutter/src/rendering/viewport.dart:1182:6)
I/flutter (19228): #2 RenderObject.layout (package:flutter/src/rendering/object.dart:1619:9)
I/flutter (19228): #3 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #4 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #5 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #6 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #7 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #8 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #9 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #10 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #11 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #12 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #13 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #14 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #15 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #16 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #17 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #18 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #19 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #20 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #21 RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:258:13)
I/flutter (19228): #22 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #23 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:549:15)
I/flutter (19228): #24 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #25 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11)
I/flutter (19228): #26 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:339:7)
I/flutter (19228): #27 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7)
I/flutter (19228): #28 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14)
I/flutter (19228): #29 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #30 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #31 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #32 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #33 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1188:11)
I/flutter (19228): #34 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #35 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #36 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #37 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #38 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #39 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #40 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #41 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #42 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #43 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #44 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #45 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #46 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #47 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #48 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #49 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #50 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:2881:13)
I/flutter (19228): #51 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #52 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
I/flutter (19228): #53 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #54 __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #55 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #56 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #57 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #58 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #59 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #60 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #61 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #62 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #63 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #64 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #65 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #66 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #67 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #68 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #69 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #70 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #71 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #72 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #73 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #74 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #75 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #76 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #77 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #78 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #79 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #80 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #81 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:2881:13)
I/flutter (19228): #82 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #83 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
I/flutter (19228): #84 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #85 __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #86 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #87 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #88 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #89 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #90 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #91 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #92 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #93 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #94 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #95 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (19228): #96 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (19228): #97 RenderView.performLayout (package:flutter/src/rendering/view.dart:147:13)
I/flutter (19228): #98 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
I/flutter (19228): #99 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
I/flutter (19228): #100 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
I/flutter (19228): #101 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:677:13)
I/flutter (19228): #102 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter (19228): #103 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (19228): #104 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (19228): #105 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:751:7)
I/flutter (19228): #107 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
I/flutter (19228): #108 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
I/flutter (19228): #109 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter (19228): (elided one frame from package dart:async)
I/flutter (19228):
I/flutter (19228): The following RenderObject was being processed when the exception was fired:
I/flutter (19228): RenderViewport#90797 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (19228): creator: Viewport ← _ScrollableScope ← IgnorePointer-[GlobalKey#3c2b1] ← Semantics ← Listener ←
I/flutter (19228): _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#cd194] ←
I/flutter (19228): _ScrollSemantics-[GlobalKey#45621] ← RepaintBoundary ← CustomPaint ← RepaintBoundary ←
I/flutter (19228): NotificationListener<ScrollNotification> ← ⋯
I/flutter (19228): parentData: <none> (can use size)
I/flutter (19228): constraints: BoxConstraints(0.0<=w<=Infinity, h=180.0)
I/flutter (19228): size: MISSING
I/flutter (19228): axisDirection: right
I/flutter (19228): crossAxisDirection: down
I/flutter (19228): offset: _PagePosition#6c97d(offset: null, range: null..null, viewport: null, ScrollableState,
I/flutter (19228): PageScrollPhysics -> ClampingScrollPhysics, IdleScrollActivity#73c09, ScrollDirection.idle)
I/flutter (19228): anchor: 0.0
I/flutter (19228): This RenderObject had the following child:
I/flutter (19228): RenderSliverFillViewport#ce224 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (19228): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderViewport#90797 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderViewport#90797 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#598aa relayoutBoundary=up11 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#4c977 relayoutBoundary=up10 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderPointerListener#2c082 relayoutBoundary=up9 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#e6e8c relayoutBoundary=up8 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#92ccd relayoutBoundary=up7 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#443e3 relayoutBoundary=up6 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#4e459 relayoutBoundary=up5 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#954aa relayoutBoundary=up4 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#1354c relayoutBoundary=up3 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderConstrainedBox#b5d9f relayoutBoundary=up2 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#1354c relayoutBoundary=up3
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#954aa relayoutBoundary=up4 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderConstrainedBox#b5d9f relayoutBoundary=up2
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#1354c relayoutBoundary=up3
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#954aa relayoutBoundary=up4 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: 'package:flutter/src/rendering/object.dart': Failed assertion: line 1578 pos 12: '!_debugDoingThisLayout': is not true.
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#1354c relayoutBoundary=up3
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#954aa relayoutBoundary=up4 NEEDS-PAINT
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#1354c relayoutBoundary=up3
I/chatty (19228): uid=10100(com.example.mapview) Thread-2 identical 13 lines
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#1354c relayoutBoundary=up3
I/flutter (19228): Another exception was thrown: 'package:flutter/src/rendering/object.dart': Failed assertion: line 1578 pos 12: '!_debugDoingThisLayout': is not true.
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderDecoratedBox#1354c relayoutBoundary=up3
I/flutter (19228): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#954aa relayoutBoundary=up4 NEEDS-PAINT
Here is the code of my Stack
return new MaterialApp(
home: Scaffold(
appBar: new AppBar(title: new Text("Commonwealth Walkway Offline Map")),
body: Stack(
children: <Widget>[
FlutterMap(
mapController: mapController,
options: new MapOptions(
center: new LatLng(51.1747, -115.56934),
minZoom: 13.0,
maxZoom: 16.0,
zoom: 14.0,
swPanBoundary: LatLng(51.16968, -115.58628),
nePanBoundary: LatLng(51.1883, -115.5516),
),
layers: [
new TileLayerOptions(
offlineMode: true,
maxZoom: 16,
urlTemplate: "assets/map/banff/{z}/{x}/{y}.png",
),
new MarkerLayerOptions(
markers: generateMarkers(
markers,
swiperController.move,
_currentIndex,
LatLng(51.17360, -115.57140),
_direction)), //_currentLocation
],
),
Positioned(
bottom: 1.0,
child: Container(
color: Colors.blue,
height: 150.0,
child: Swiper(
itemBuilder: (BuildContext context, index) {
return Carousels(markers[index], _update);
},
itemCount: markers.length,
viewportFraction: 0.8,
scale: 0.9,
loop: false,
controller: swiperController,
onIndexChanged: (index) {
setState(() {
_currentIndex = index;
});
},
),
),
)
],
),
),
);
The Swiper/Carousel package can be found here: https://pub.dartlang.org/packages/flutter_swiper#-readme-tab-
As your log explains :
"constraints: BoxConstraints(0.0<=w<=Infinity, h=180.0)"
you have to define the width of the Container which is the parent of your Swiper. You have to also organize the items inside your stack which aren't positioned using rows and columns to keep its layout consistent across different screens.
add this line inside your Container :
width: MediaQuery.of(context).size.width,
this will make your Swiper fill the screen width, you can modify it to any other value to suit your design.

No Directionality widget found. InkWell widgets require a Directionality widget ancestor

I am totally new to flutter and my first Steps already caused errors I cant solve by my own or searching this website..
I want to create a Button but get an Execption of missing Directionality as I understand. The only widget which needs the textDirection is the Text Widget, but it has ist, so whats wrong here? A Full Start also already tried several times incl. new emulator..
This is my code:
import 'package:flutter/material.dart';
void main(){
runApp(
new MyStatefullWidget()
) ;
}
class MyStatefullWidget extends StatefulWidget {
#override
_MyStatefullWidgetState createState() => _MyStatefullWidgetState();
}
class _MyStatefullWidgetState extends State<MyStatefullWidget> {
#override
Widget build(BuildContext context) {
return Container(
color:Colors.red,
child: Center(
child: RaisedButton(
child: Text("klick mich", textDirection: TextDirection.ltr),
onPressed: (){
print("Hi");
},
),
),
);
}
}
and this is the Error message:
I/flutter ( 4763): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 4763): The following assertion was thrown building InkWell(gestures: [tap], clipped to BoxShape.rectangle,
I/flutter ( 4763): dirty, state: _InkResponseState<InkResponse>#43345):
I/flutter ( 4763): No Directionality widget found.
I/flutter ( 4763): InkWell widgets require a Directionality widget ancestor.
I/flutter ( 4763): The specific widget that could not find a Directionality ancestor was:
I/flutter ( 4763): InkWell(gestures: [tap], clipped to BoxShape.rectangle)
I/flutter ( 4763): The ownership chain for the affected widget is:
I/flutter ( 4763): InkWell ← DefaultTextStyle ← AnimatedDefaultTextStyle ← _InkFeatures-[GlobalKey#64251 ink
I/flutter ( 4763): renderer] ← NotificationListener<LayoutChangedNotification> ← CustomPaint ← _ShapeBorderPaint ←
I/flutter ( 4763): PhysicalShape ← _MaterialInterior ← Material ← ⋯
I/flutter ( 4763): Typically, the Directionality widget is introduced by the MaterialApp or WidgetsApp widget at the
I/flutter ( 4763): top of your application widget tree. It determines the ambient reading direction and is used, for
I/flutter ( 4763): example, to determine how to lay out text, how to interpret "start" and "end" values, and to resolve
I/flutter ( 4763): EdgeInsetsDirectional, AlignmentDirectional, and other *Directional objects.
I/flutter ( 4763):
I/flutter ( 4763): When the exception was thrown, this was the stack:
I/flutter ( 4763): #0 debugCheckHasDirectionality.<anonymous closure> (package:flutter/src/widgets/debug.dart:241:7)
I/flutter ( 4763): #1 debugCheckHasDirectionality (package:flutter/src/widgets/debug.dart:257:4)
I/flutter ( 4763): #2 InkResponse.debugCheckContext (package:flutter/src/material/ink_well.dart:376:12)
I/flutter ( 4763): #3 _InkResponseState.build (package:flutter/src/material/ink_well.dart:554:19)
I/flutter ( 4763): #4 StatefulElement.build (package:flutter/src/widgets/framework.dart:3809:27)
I/flutter ( 4763): #5 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3721:15)
I/flutter ( 4763): #6 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #7 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #8 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 4763): #9 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #10 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #11 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #12 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #13 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #14 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #15 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #16 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #17 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #18 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #19 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #20 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #21 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 4763): #22 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #25 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #28 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #29 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #30 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #31 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #32 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #33 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #34 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #35 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #36 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #37 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #38 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #39 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #40 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #41 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #42 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #43 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #44 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #45 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #46 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #47 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #48 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #49 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 4763): #50 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #51 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #52 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #53 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #54 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #55 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #56 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 4763): #57 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #58 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #59 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #60 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #61 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #62 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #63 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #64 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #65 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #66 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #67 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #68 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #69 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #70 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #71 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #72 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 4763): #73 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #74 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #75 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #76 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #77 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #78 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #79 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #80 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #81 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #82 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #83 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #84 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #85 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4763): #86 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #87 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #88 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #89 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #90 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #91 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #92 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #93 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #94 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4763): #95 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4763): #96 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4763): #97 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 4763): #98 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4763): #99 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4763): #100 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4763): #101 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:909:16)
I/flutter ( 4763): #102 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:880:5)
I/flutter ( 4763): #103 RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:826:17)
I/flutter ( 4763): #104 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2266:19)
I/flutter ( 4763): #105 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:825:13)
I/flutter ( 4763): #106 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:712:7)
I/flutter ( 4763): #107 runApp (package:flutter/src/widgets/binding.dart:756:7)
I/flutter ( 4763): #108 main (package:flutter_app/main.dart:4:3)
I/flutter ( 4763): #109 _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:289:19)
I/flutter ( 4763): #110 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter ( 4763): ════════════════════════════════════════════════════════════════════════════════════════════════════
You have to add a MaterialApp widget before container, like this:
class _MyStatefullWidgetState extends State<MyStatefullWidget> {
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Container(
color: Colors.red,
child: Center(
child: RaisedButton(
child: Text("klick mich", textDirection: TextDirection.ltr),
onPressed: () {
print("Hi");
},
),
),
),
);
}
}
I had this same error and to add more info, was able to resolve by looking at the error message, but the short of it is we can use MaterialApp or WidgetsApp at the top of the widget tree (as shown above):
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following assertion was thrown building InkWell(gestures: [tap], clipped to BoxShape.rectangle,
dirty, state: _InkResponseState#1b61e):
No Directionality widget found.
InkWell widgets require a Directionality widget ancestor.
The specific widget that could not find a Directionality ancestor was:
InkWell
The ownership chain for the affected widget is: "InkWell ← DefaultTextStyle ←
AnimatedDefaultTextStyle ← _InkFeatures-[GlobalKey#3bd76 ink renderer] ←
NotificationListener ← CustomPaint ← _ShapeBorderPaint ← PhysicalShape
← _MaterialInterior ← Material ← ⋯"
Typically, the Directionality widget is introduced by the MaterialApp or WidgetsApp widget at the
top of your application widget tree. It determines the ambient reading direction and is used, for
example, to determine how to lay out text, how to interpret "start" and "end" values, and to resolve
EdgeInsetsDirectional, AlignmentDirectional, and other *Directional objects.

Error: '_elements.contains(element)': is not true

I am seeing this error '_elements.contains(element)': is not true.for the past two days in my flutter project, this was working absolutely fine since the beginning. I am sorry to say this but I have no clue regarding this error but i think i am missing something which is causing this error. Also, when I hot reload the same page the layout is populated, but throws the exceptions.
Intermittently this was also showing Duplicate GlobalKeys() detected, but this wasn't the case in the beginning.
Please can someone help me if they stumbled upon these errors before. I couldn't really write an example to reproduce the same problem. Many thanks.
I have given the error details as follows:
Performing hot reload...
I/flutter (22248): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY
╞═══════════════════════════════════════════════════════════
I/flutter (22248): The following assertion was thrown building
TickerMode(mode: disabled):
I/flutter (22248): 'package:flutter/src/widgets/framework.dart': Failed
assertion: line 1766 pos 12:
I/flutter (22248): '_elements.contains(element)': is not true.
I/flutter (22248):
I/flutter (22248): Either the assertion indicates an error in the framework
itself, or we should provide substantially
I/flutter (22248): more information in this error message to help you
determine and fix the underlying cause.
I/flutter (22248): In either case, please report this assertion by filing a
bug on GitHub:
I/flutter (22248): https://github.com/flutter/flutter/issues/new
I/flutter (22248):
I/flutter (22248): When the exception was thrown, this was the stack:
I/flutter (22248): #2 _InactiveElements.remove
(package:flutter/src/widgets/framework.dart:1766:12)
I/flutter (22248): #3 Element._retakeInactiveElement
(package:flutter/src/widgets/framework.dart:2850:29)
I/flutter (22248): #4 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:2873:32)
I/flutter (22248): #5 Element.updateChild
(package:flutter/src/widgets/framework.dart:2688:12)
I/flutter (22248): #6 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #7 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #8 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #9 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #10 RenderObjectElement.updateChildren
(package:flutter/src/widgets/framework.dart:4262:32)
I/flutter (22248): #11 _TheatreElement.update
(package:flutter/src/widgets/overlay.dart:508:17)
I/flutter (22248): #12 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #13 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #14 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #15 StatefulElement.update
(package:flutter/src/widgets/framework.dart:3682:5)
I/flutter (22248): #16 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #17 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #18 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #19 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #20 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #21 SingleChildRenderObjectElement.update
(package:flutter/src/widgets/framework.dart:4535:14)
I/flutter (22248): #22 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #23 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #24 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #25 StatefulElement.update
(package:flutter/src/widgets/framework.dart:3682:5)
I/flutter (22248): #26 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #27 SingleChildRenderObjectElement.update
(package:flutter/src/widgets/framework.dart:4535:14)
I/flutter (22248): #28 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #29 SingleChildRenderObjectElement.update
(package:flutter/src/widgets/framework.dart:4535:14)
I/flutter (22248): #30 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #31 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #32 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #33 StatefulElement.update
(package:flutter/src/widgets/framework.dart:3682:5)
I/flutter (22248): #34 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #35 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #36 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #37 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #38 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #39 SingleChildRenderObjectElement.update
(package:flutter/src/widgets/framework.dart:4535:14)
I/flutter (22248): #40 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #41 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #42 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #43 StatelessElement.update
(package:flutter/src/widgets/framework.dart:3607:5)
I/flutter (22248): #44 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #45 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #46 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #47 StatelessElement.update
(package:flutter/src/widgets/framework.dart:3607:5)
I/flutter (22248): #48 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #49 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #50 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #51 StatelessElement.update
(package:flutter/src/widgets/framework.dart:3607:5)
I/flutter (22248): #52 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #53 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #54 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #55 StatelessElement.update
(package:flutter/src/widgets/framework.dart:3607:5)
I/flutter (22248): #56 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #57 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #58 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #59 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #60 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #61 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #62 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #63 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #64 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #65 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #66 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #67 StatefulElement.update
(package:flutter/src/widgets/framework.dart:3682:5)
I/flutter (22248): #68 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #69 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #70 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #71 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #72 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #73 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #74 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #75 StatefulElement.update
(package:flutter/src/widgets/framework.dart:3682:5)
I/flutter (22248): #76 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #77 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #78 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #79 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #80 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #81 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #82 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #83 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #84 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #85 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #86 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #87 StatelessElement.update
(package:flutter/src/widgets/framework.dart:3607:5)
I/flutter (22248): #88 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #89 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #90 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #91 StatefulElement.update
(package:flutter/src/widgets/framework.dart:3682:5)
I/flutter (22248): #92 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #93 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #94 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #95 ProxyElement.update
(package:flutter/src/widgets/framework.dart:3792:5)
I/flutter (22248): #96 Element.updateChild
(package:flutter/src/widgets/framework.dart:2677:15)
I/flutter (22248): #97 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:3557:16)
I/flutter (22248): #98 Element.rebuild
(package:flutter/src/widgets/framework.dart:3446:5)
I/flutter (22248): #99 BuildOwner.buildScope
(package:flutter/src/widgets/framework.dart:2246:33)
I/flutter (22248): #100
BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&Renderer
Binding&WidgetsBinding.drawFrame
(package:flutter/src/widgets/binding.dart:580:20)
I/flutter (22248): #101
BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&Renderer
Binding._handlePersistentFrameCallback
(package:flutter/src/rendering/binding.dart:200:5)
I/flutter (22248): #102
BindingBase&SchedulerBinding._invokeFrameCallback
(package:flutter/src/scheduler/binding.dart:713:15)
I/flutter (22248): #103 BindingBase&SchedulerBinding.handleDrawFrame
(package:flutter/src/scheduler/binding.dart:649:9)
I/flutter (22248): #104
BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&Renderer
Binding.scheduleWarmUpFrame.<anonymous closure>
(package:flutter/src/rendering/binding.dart:286:20)
I/flutter (22248): #106 _Timer._runTimers (dart:isolate-
patch/dart:isolate/timer_impl.dart:367)
I/flutter (22248): #107 _Timer._handleMessage (dart:isolate-
patch/dart:isolate/timer_impl.dart:401)
I/flutter (22248): #108 _RawReceivePortImpl._handleMessage
(dart:isolate-patch/dart:isolate/isolate_patch.dart:163)
I/flutter (22248): (elided 3 frames from class _AssertionError and
package dart:async-patch)
I/flutter (22248):
══════════════════════════════════════════════════════════════════════════
══════════════════════════
Reloaded 0 of 492 libraries in 823ms.
I have included a sample example of what i am trying to do in my application.
main.dart
import 'package:flutter/rendering.dart';
import 'package:flutter/material.dart';
import 'package:untitled3/secondwidget.dart';
void main() {
runApp(
new Example(),
);
}
class Example extends StatefulWidget {
#override
_ExampleState createState() => new _ExampleState();
}
class _ExampleState extends State<Example> {
int noOfBranches;
#override
void initState() {
super.initState();
getCount();
}
void getCount() {
print('list builder count is ${noOfBranches}');
}
#override
Widget build(BuildContext context) {
setState(() {
noOfBranches = 2;
});
return new MaterialApp(
home: new Scaffold(
body: new ListView.builder(
itemCount: noOfBranches,
itemBuilder: (BuildContext context, int index) {
return new Card(
child: new FlatButton(
onPressed: (() {
Navigator.push(
context,
new MaterialPageRoute(
builder: (_) => new SecondWidget()));
}),
child: new Text('Next Widget')),
);
}),
),
);
}
}
secondwidget.dart
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
class SecondWidget extends StatefulWidget {
#override
_SecondWidgetState createState() => new _SecondWidgetState();
}
class _SecondWidgetState extends State<SecondWidget> {
#override
Widget build(BuildContext context) {
return new Container(
child: new Text('Second Widget'),
);
}
}
I don't see the error in my application if setState() declare as given in the example main.dart file inside the
#override
Widget build(BuildContext context) {
setState(() {
noOfBranches = 2;
});
.....
}
but I only see this error if I declare the setState() inside the getCount() function.
I am not so sure why this is the case.
I am actually stuck on this error for two days and any help would be greatly appreciated.
Many Thanks,
Mahi
I think I kinda solved the error by declaring the setState() inside the
#override
Widget build(BuildContext context) {
setState(() {
noOfBranches = 2;
});
print('noof branches inside widget build = $noOfBranches');
.....
}
Now the app is running absolutely fine without any problems.
But, I would be grateful if there are any more suggestions as I am new to programming and would be very very happy to learn more.
The only problem was the setState() was modifying the context and when clicked on the button to call another widget it was throwing up with this error message.
Many Thanks,
Mahi.
Why don't you set your noOfBranches variable not in the initState method?
#override
void initState() {
super.initState();
noOfBranches = 2;
}

Resources