This is my problem and I don't know how can fix it. Please help me
Github of this project: here
Launching lib/main.dart on iPhone SE (2nd generation) in debug mode...
Running Xcode build...
Xcode build done. 22.0s
Configuring the default Firebase app...
Configured the default Firebase app __FIRAPP_DEFAULT.
Waiting for iPhone SE (2nd generation) to report its views...
Debug service listening on ws://127.0.0.1:54630/tFUTjcfl640=/ws
Syncing files to device iPhone SE (2nd generation)...
flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following assertion was thrown building StreamBuilder<CalendarDetailModel>(dirty, state:
flutter: _StreamBuilderBaseState<CalendarDetailModel, AsyncSnapshot<CalendarDetailModel>>#836df):
flutter: A build function returned null.
flutter: The offending widget is:
flutter: StreamBuilder<CalendarDetailModel>
flutter: Build functions must never return null.
flutter: To return an empty space that causes the building widget to fill available room, return
flutter: "Container()". To return an empty space that takes as little room as possible, return
flutter: "Container(width: 0.0, height: 0.0)".
flutter:
flutter: The relevant error-causing widget was:
flutter: StreamBuilder<CalendarDetailModel>
flutter: file:///Users/lethanhtu/Desktop/firebase_authentication/lib/ui/calendar_detail.dart:54:20
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 debugWidgetBuilderValue.<anonymous closure> (package:flutter/src/widgets/debug.dart:276:7)
flutter: #1 debugWidgetBuilderValue (package:flutter/src/widgets/debug.dart:297:4)
flutter: #2 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4516:7)
flutter: #3 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4684:11)
flutter: #4 Element.rebuild (package:flutter/src/widgets/framework.dart:4227:5)
flutter: #5 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4490:5)
flutter: #6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4675:11)
flutter: #7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4485:5)
flutter: ... Normal element mounting (39 frames)
flutter: #46 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3455:14)
flutter: #47 Element.updateChild (package:flutter/src/widgets/framework.dart:3223:18)
flutter: #48 SliverMultiBoxAdaptorElement.updateChild (package:flutter/src/widgets/sliver.dart:1162:36)
flutter: #49 SliverMultiBoxAdaptorElement.createChild.<anonymous closure> (package:flutter/src/widgets/sliver.dart:1147:20)
flutter: #50 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2612:19)
flutter: #51 SliverMultiBoxAdaptorElement.createChild (package:flutter/src/widgets/sliver.dart:1140:11)
flutter: #52 RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure> (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:354:23)
flutter: #53 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1866:58)
flutter: #54 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:918:15)
flutter: #55 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1866:13)
flutter: #56 RenderSliverMultiBoxAdaptor._createOrObtainChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:343:5)
flutter: #57 RenderSliverMultiBoxAdaptor.addInitialChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:427:5)
flutter: #58 RenderSliverList.performLayout (package:flutter/src/rendering/sliver_list.dart:79:12)
flutter: #59 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #60 RenderSliverEdgeInsetsPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:135:11)
flutter: #61 RenderSliverPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:375:11)
flutter: #62 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #63 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:452:13)
flutter: #64 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1443:12)
flutter: #65 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1352:20)
flutter: #66 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #67 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #68 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #69 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #70 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #71 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #72 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #73 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #74 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #75 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #76 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #77 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #78 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #79 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #80 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #81 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #82 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #83 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:207:11)
flutter: #84 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #85 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:171:11)
flutter: #86 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:480:7)
flutter: #87 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:240:7)
flutter: #88 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:399:14)
flutter: #89 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #90 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #91 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #92 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #93 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1267:11)
flutter: #94 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #95 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #96 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #97 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #98 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #99 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #100 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #101 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:556:15)
flutter: #102 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #103 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #104 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #105 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #106 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #107 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #108 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #109 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #110 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #111 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #112 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #113 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #114 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3219:13)
flutter: #115 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #116 _RenderTheatre.performLayout (package:flutter/src/widgets/overlay.dart:700:15)
flutter: #117 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #118 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #119 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #120 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #121 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #122 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #123 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #124 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #125 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #126 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #127 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #128 RenderView.performLayout (package:flutter/src/rendering/view.dart:167:13)
flutter: #129 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1630:7)
flutter: #130 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:887:18)
flutter: #131 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:402:19)
flutter: #132 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:865:13)
flutter: #133 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:284:5)
flutter: #134 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1113:15)
flutter: #135 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1052:9)
flutter: #136 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:861:7)
flutter: (elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
flutter:
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Status code is 200
[VERBOSE-2:ui_dart_state.cc(166)] Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'Map<String, String>'
#0 new CalendarDetailModel (package:firebaseauthentication/models/calendar_detail_model.dart:26:40)
#1 CalendarDetailRepository.fetchRoom.<anonymous closure> (package:firebaseauthentication/resources/calendar_detail_repository.dart:38:23)
#2 List.forEach (dart:core-patch/growable_array.dart:289:8)
#3 CalendarDetailRepository.fetchRoom (package:firebaseauthentication/resources/calendar_detail_repository.dart:35:19)
<asynchronous suspension>
#4 CalendarDetailBloc.loadRoom (package:firebaseauthentication/blocs/calendar_detail_bloc.dart:16:36)
#5 CalendarDetailsState.initState (package:firebaseauthentication/ui/calendar_detail.dart:35:10)
#6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4649:58)
#7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4485:5)
#8 Element.inflateWidget (package:flutter/<…>
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building StreamBuilder<CalendarDetailModel>(dirty, state: _StreamBuilderBaseState<CalendarDetailModel, AsyncSnapshot<CalendarDetailModel>>#836df):
A build function returned null.
The offending widget is: StreamBuilder<CalendarDetailModel>
Build functions must never return null.
To return an empty space that causes the building widget to fill available room, return "Container()". To return an empty space that takes as little room as possible, return "Container(width: 0.0, height: 0.0)".
The relevant error-causing widget was:
StreamBuilder<CalendarDetailModel> file:///Users/lethanhtu/Desktop/firebase_authentication/lib/ui/calendar_detail.dart:54:20
When the exception was thrown, this was the stack:
#0 debugWidgetBuilderValue.<anonymous closure> (package:flutter/src/widgets/debug.dart:276:7)
#1 debugWidgetBuilderValue (package:flutter/src/widgets/debug.dart:297:4)
#2 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4516:7)
#3 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4684:11)
#4 Element.rebuild (package:flutter/src/widgets/framework.dart:4227:5)
...
════════════════════════════════════════════════════════════════════════════════════════════════════
The error is quite clear about what the issue is. In you StreamBuilder you are not awlays returning something. You have:
builder: (context, snapshot) {
if (snapshot.hasError) {
return CircularProgressIndicator();
} else if (snapshot.hasData) {
...
}
which only returns something on an error or when data is available. However, there won't always be data available or an error, so you have to return something when neither of these conditions are true.
Simply adding return CircularProgressIndicator(); outside of these if-else blocks or in an else statement will solve your issue.
Ex.
builder: (context, snapshot) {
if (snapshot.hasError) {
return CircularProgressIndicator();
} else if (snapshot.hasData) {
...
}
else {
return CircularProgressIndicator();
}
Following the instructions that these errors provide can save you a lot of time and takes away the need to ask here on SO.
Related
I am trying to pass a class inside the Stack to the ListView, but it does not display on the screen as it should and gives an error
Restarted application in 1 071ms.
════════ Exception caught by widgets library
═══════════════════════════════════ The following assertion was thrown
while applying parent data.: Incorrect use of ParentDataWidget.
The ParentDataWidget Positioned(left: 154.0, top: 21.0, width: 73.0,
height: 366.0) wants to apply ParentData of type StackParentData to a
RenderObject, which has been set up to accept ParentData of
incompatible type ParentData.
Usually, this means that the Positioned widget has the wrong ancestor
RenderObjectWidget. Typically, Positioned widgets are placed directly
inside Stack widgets. The offending Positioned is currently placed
inside a RepaintBoundary widget.
The ownership chain for the RenderObject that received the
incompatible parent data was: SizedBox ← Positioned ←
MyRandomizedButton-[<'0'>] ← RepaintBoundary ← IndexedSemantics ←
NotificationListener ← KeepAlive ←
AutomaticKeepAlive ← KeyedSubtree-[Key <[<'0'>]>] ← SliverList ← ⋯
When the exception was thrown, this was the stack
#0 RenderObjectElement._updateParentData.
#1 RenderObjectElement._updateParentData
#2 RenderObjectElement.attachRenderObject
#3 RenderObjectElement.mount
#4 SingleChildRenderObjectElement.mount ... Normal element mounting (47 frames)
#51 Element.inflateWidget
#52 Element.updateChild
#53 SliverMultiBoxAdaptorElement.updateChild
#54 SliverMultiBoxAdaptorElement.createChild.
#55 BuildOwner.buildScope
#56 SliverMultiBoxAdaptorElement.createChild
#57 RenderSliverMultiBoxAdaptor._createOrObtainChild.
#58 RenderObject.invokeLayoutCallback.
#59 PipelineOwner._enableMutationsToDirtySubtrees
#60 RenderObject.invokeLayoutCallback
#61 RenderSliverMultiBoxAdaptor._createOrObtainChild
#62 RenderSliverMultiBoxAdaptor.addInitialChild
#63 RenderSliverList.performLayout
#64 RenderObject.layout
#65 RenderSliverEdgeInsetsPadding.performLayout
#66 RenderSliverPadding.performLayout
#67 RenderObject.layout
#68 RenderViewportBase.layoutChildSequence
#69 RenderViewport._attemptLayout
#70 RenderViewport.performLayout
#71 RenderObject.layout
#72 RenderProxyBoxMixin.performLayout
#73 RenderObject.layout
#74 RenderProxyBoxMixin.performLayout
#75 RenderObject.layout
#76 RenderProxyBoxMixin.performLayout
#77 RenderObject.layout
#78 RenderProxyBoxMixin.performLayout
#79 RenderObject.layout
#80 RenderProxyBoxMixin.performLayout
#81 RenderObject.layout
#82 RenderProxyBoxMixin.performLayout
#83 RenderObject.layout
#84 RenderProxyBoxMixin.performLayout
#85 RenderObject.layout
#86 RenderProxyBoxMixin.performLayout
#87 RenderCustomPaint.performLayout
#88 RenderObject.layout
#89 RenderProxyBoxMixin.performLayout
#90 RenderObject.layout
#91 ChildLayoutHelper.layoutChild
#92 RenderStack._computeSize
#93 RenderStack.performLayout
#94 RenderObject.layout
#95 MultiChildLayoutDelegate.layoutChild
#96 _ScaffoldLayout.performLayout
#97 MultiChildLayoutDelegate._callPerformLayout
#98 RenderCustomMultiChildLayoutBox.performLayout
#99 RenderObject.layout
#100 RenderProxyBoxMixin.performLayout
#101 RenderObject.layout
#102 RenderProxyBoxMixin.performLayout
#103 _RenderCustomClip.performLayout
#104 RenderObject.layout
#105 MultiChildLayoutDelegate.layoutChild
#106 _ScaffoldLayout.performLayout
#107 MultiChildLayoutDelegate._callPerformLayout
#108 RenderCustomMultiChildLayoutBox.performLayout
#109 RenderObject.layout
#110 RenderProxyBoxMixin.performLayout
#111 RenderObject.layout
#112 RenderProxyBoxMixin.performLayout
#113 _RenderCustomClip.performLayout
#114 RenderObject.layout
#115 RenderProxyBoxMixin.performLayout
#116 RenderObject.layout
#117 RenderProxyBoxMixin.performLayout
#118 RenderObject.layout
#119 RenderProxyBoxMixin.performLayout
#120 RenderObject.layout
#121 RenderProxyBoxMixin.performLayout
#122 RenderObject.layout
#123 RenderProxyBoxMixin.performLayout
#124 RenderObject.layout
#125 RenderProxyBoxMixin.performLayout
#126 RenderObject.layout
#127 RenderProxyBoxMixin.performLayout
#128 RenderObject.layout
#129 RenderProxyBoxMixin.performLayout
#130 RenderObject.layout
#131 RenderProxyBoxMixin.performLayout
#132 RenderObject.layout
#133 RenderProxyBoxMixin.performLayout
#134 RenderObject.layout
#135 RenderProxyBoxMixin.performLayout
#136 RenderObject.layout
#137 RenderProxyBoxMixin.performLayout
#138 RenderObject.layout
#139 RenderProxyBoxMixin.performLayout
#140 RenderObject.layout
#141 RenderProxyBoxMixin.performLayout
#142 RenderObject.layout
#143 RenderProxyBoxMixin.performLayout
#144 RenderObject.layout
#145 RenderProxyBoxMixin.performLayout
#146 RenderObject.layout
#147 RenderProxyBoxMixin.performLayout
#148 RenderOffstage.performLayout
#149 RenderObject.layout
#150 RenderProxyBoxMixin.performLayout
#151 RenderObject.layout
#152 _RenderTheatre.performLayout
#153 RenderObject.layout
#154 RenderProxyBoxMixin.performLayout
#155 RenderObject.layout
#156 RenderProxyBoxMixin.performLayout
#157 RenderObject.layout
#158 RenderProxyBoxMixin.performLayout
#159 RenderObject.layout
#160 RenderProxyBoxMixin.performLayout
#161 RenderCustomPaint.performLayout
#162 RenderObject.layout
#163 RenderProxyBoxMixin.performLayout
#164 RenderObject.layout
#165 RenderProxyBoxMixin.performLayout
#166 RenderObject.layout
#167 RenderProxyBoxMixin.performLayout
#168 RenderObject.layout
#169 RenderProxyBoxMixin.performLayout
#170 RenderObject.layout
#171 RenderView.performLayout
#172 RenderObject._layoutWithoutResize
#173 PipelineOwner.flushLayout
#174 RendererBinding.drawFrame
#175 WidgetsBinding.drawFrame
#176 RendererBinding._handlePersistentFrameCallback
#177 SchedulerBinding._invokeFrameCallback
#178 SchedulerBinding.handleDrawFrame
#179 SchedulerBinding.scheduleWarmUpFrame. (elided 11 frames from class _RawReceivePortImpl, class _Timer,
dart:async, and dart:async-patch)
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library
═══════════════════════════════════ Incorrect use of ParentDataWidget.
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library
═══════════════════════════════════ Incorrect use of ParentDataWidget.
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library
═══════════════════════════════════ Incorrect use of ParentDataWidget.
════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library
═══════════════════════════════════ Incorrect use of ParentDataWidget.
════════════════════════════════════════════════════════════════════════════════
in the console. When I just pass the class inside the Stack by manually changing the Key, everything works as it should. How can I fix this?
The widget that gives an error:
class MainScreenWidget extends StatefulWidget {
const MainScreenWidget({Key? key}) : super(key: key);
#override
State<MainScreenWidget> createState() => _MainScreenWidgetState();
}
class _MainScreenWidgetState extends State<MainScreenWidget> {
#override
Widget build(BuildContext context) {
SystemChrome.setEnabledSystemUIOverlays([]);
return Scaffold(
body: Stack(
children: [
ListView.builder(
itemCount: 5,
itemBuilder: (context, index) {
return MyRandomizedButton(key: ValueKey(index.toString()));
})
],
),
);
}
}
As mentioned in the docs
A Positioned widget must be a descendant of a Stack.
Please Wrap your Positioned widget inside a stack
Stack(
children: [
Positioned(
/// remaining code
]
)
Please update the MyRandomizedButton code and the complete error you are getting in your console.
You are using a positioned widget as the parent of the sized box which is creating an issue. The positioned widget can only be used inside a stack. So you can try to update your listview.builder inside a positioned widget instead of a sized box. Here is an example code. Let me know if this works for you.
class MainScreenWidget extends StatefulWidget {
const MainScreenWidget({Key? key}) : super(key: key);
#override
State<MainScreenWidget> createState() => _MainScreenWidgetState();
}
class _MainScreenWidgetState extends State<MainScreenWidget> {
#override
Widget build(BuildContext context) {
final maxWidth = MediaQuery.of(context).size.width;
final maxHeight = MediaQuery.of(context).size.height;
final random = Random();
int minT = 3;
int maxT = maxHeight.toInt() - 80;
int randomTop = minT + random.nextInt(maxT - minT);
int minL = 3;
int maxL = maxWidth.toInt() - 80;
int randomLeft = minL + random.nextInt(maxL - minL);
int minH = 70;
int maxH = maxHeight.toInt() - randomTop;
int randomHeight = minH + random.nextInt(maxH - minH);
int minW = 70;
int maxW = maxWidth.toInt() - randomLeft;
int randomWidth = minW + random.nextInt(maxW - minW);
int minR = 1;
int maxR = 75;
int randomRadius = minR + random.nextInt(maxR - minR);
SystemChrome.setEnabledSystemUIOverlays([]);
return Scaffold(
body: Stack(
children: [
Positioned(
height: randomHeight.toDouble(),
width: randomWidth.toDouble(),
top: randomTop.toDouble(),
left: randomLeft.toDouble(),
child: ListView.builder(
itemCount: 5,
itemBuilder: (context, index) {
return MyRandomizedButton(key: ValueKey(index.toString()));
}),
)
// MyRandomizedButton(key: ValueKey("0")),
],
),
);
}
}
Lately i've been trying to update a profile.
So here's the scenario ,
HomePage => Drawer => Profile => HomePage .
When i return , this is the error i get.
⡿flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following assertion was thrown building BlocListener<HomeBloc, HomeState>(dirty, state:
flutter: _BlocListenerBaseState<HomeBloc, HomeState>#4a7df):
flutter: A build function returned null.
flutter: The offending widget is:
flutter: BlocListener<HomeBloc, HomeState>
flutter: Build functions must never return null.
flutter: To return an empty space that causes the building widget to fill available room, return
flutter: "Container()". To return an empty space that takes as little room as possible, return
flutter: "Container(width: 0.0, height: 0.0)".
flutter:
flutter: The relevant error-causing widget was:
flutter: BlocListener<HomeBloc, HomeState>
flutter: file:///Users/macbook/Documents/development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_bloc-6.0.6/lib/src/bloc_builder.dart:148:12
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 debugWidgetBuilderValue.<anonymous closure> (package:flutter/src/widgets/debug.dart:302:7)
flutter: #1 debugWidgetBuilderValue (package:flutter/src/widgets/debug.dart:323:4)
flutter: #2 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4632:7)
flutter: #3 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #4 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #5 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #6 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #7 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #8 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #9 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #10 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #11 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #12 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #13 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #14 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5)
flutter: #15 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #16 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #17 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #18 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #19 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #20 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #21 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #22 _InheritedProviderScopeElement.performRebuild (package:provider/src/inherited_provider.dart:426:11)
flutter: #23 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #24 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5)
flutter: #25 _InheritedProviderScopeElement.update (package:provider/src/inherited_provider.dart:446:11)
flutter: #26 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #27 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #28 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #29 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5)
flutter: #30 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #31 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #32 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #33 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5)
flutter: #34 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #35 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #36 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #37 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #38 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #39 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5)
flutter: #40 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #41 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #42 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #43 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #44 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #45 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #46 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #47 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #48 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #49 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #50 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5647:32)
flutter: #51 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6246:17)
flutter: #52 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #53 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #54 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #55 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #56 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #57 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #58 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #59 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #60 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #61 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #62 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #63 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #64 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #65 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #66 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #67 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #68 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #69 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #70 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #71 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #72 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #73 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #74 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #75 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #76 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #77 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #78 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #79 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #80 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #81 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5)
flutter: #82 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #83 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #84 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #85 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #86 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #87 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #88 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #89 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #90 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #91 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #92 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5)
flutter: #93 _InheritedNotifierElement.update (package:flutter/src/widgets/inherited_notifier.dart:183:11)
flutter: #94 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #95 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #96 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #97 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #98 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #99 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #100 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #101 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #102 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #103 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #104 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5)
flutter: #105 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #106 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #107 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #108 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #109 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #110 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #111 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #112 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #113 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5)
flutter: #114 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #115 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #116 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #117 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #118 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #119 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5)
flutter: #120 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #121 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #122 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #123 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #124 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2730:33)
flutter: #125 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:913:20)
flutter: #126 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:302:5)
flutter: #127 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1117:15)
flutter: #128 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1055:9)
flutter: #129 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:864:7)
flutter: (elided 4 frames from class _RawReceivePortImpl, class _Timer, and dart:async-patch)
flutter:
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
And this is my BlocConsumer code :
BlocConsumer<PrivateprofileBloc, PrivateprofileState>(
builder: (context, state) {
if (state is PrivateprofileInitial) {
return bodyBuild();
} else if (state is PrivateprofilePictureUpdate) {
this.user = state.user;
return bodyBuild();
} else if (state is PrivateprofileUpdate) {
this.user = state.user;
return bodyBuild();
} else if (state is PrivateprofileReturn) {
return BlocProvider(
create: (context) => HomeBloc(state.user),
child: HomePage(state.user));
}
},
listener: (context, state) {},
)
Any idea why ? the data get's updated , i get the Homepage back again with the updated data, but i get that error in the Terminal .
Because you didn't return Widget in 'else' case of BlocBuilder.
Just return empty Container in 'BlocBuilder'.
As I know that 'listener' returns 'void', you don't need to return anything.
BlocConsumer<HomeBloc, HomeState>(
builder: (context, state) {
if (state is HomeInitial) {
return buildBody();
} else if (state is HomeUpdatedUser) {
widget._user = state.user;
return buildBody();
}
return Container();
},
);
Pulling images from the network into a GridView.Builder()
The images are not displayed. View screenshot
Scaffold(
appBar: AppBar(
title: Text('Shoppy'),
),
body: GridView.builder(
padding: const EdgeInsets.all(8.0),
itemCount: loadedProducts.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 3 / 2,
crossAxisSpacing: 8.0,
mainAxisSpacing: 8.0,
),
itemBuilder: (context, index) {
return ProductItem(
loadedProducts[index].id,
loadedProducts[index].imageUrl,
loadedProducts[index].name,
);
}),
);
I/flutter (11127): ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
I/flutter (11127): The following ArgumentError was thrown resolving an image codec:
I/flutter (11127): Invalid argument(s): No host specified in URI file:///p1
I/flutter (11127):
I/flutter (11127): When the exception was thrown, this was the stack:
I/flutter (11127): #0 _HttpClient._openUrl (dart:_http/http_impl.dart:2313:9)
I/flutter (11127): #1 _HttpClient.getUrl (dart:_http/http_impl.dart:2208:48)
I/flutter (11127): #2 NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:89:59)
I/flutter (11127): #3 NetworkImage.load (package:flutter/src/painting/_network_image_io.dart:51:14)
I/flutter (11127): #4 ImageProvider.resolveStreamForKey.<anonymous closure> (package:flutter/src/painting/image_provider.dart:503:13)
I/flutter (11127): #5 ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:360:22)
I/flutter (11127): #6 ImageProvider.resolveStreamForKey (package:flutter/src/painting/image_provider.dart:501:80)
I/flutter (11127): #7 ScrollAwareImageProvider.resolveStreamForKey (package:flutter/src/widgets/scroll_aware_image_provider.dart:108:19)
I/flutter (11127): #8 ImageProvider.resolve.<anonymous closure> (package:flutter/src/painting/image_provider.dart:332:9)
I/flutter (11127): #9 ImageProvider._createErrorHandlerAndKey.<anonymous closure>.<anonymous closure> (package:flutter/src/painting/image_provider.dart:462:26)
I/flutter (11127): #10 SynchronousFuture.then (package:flutter/src/foundation/synchronous_future.dart:43:29)
I/flutter (11127): #11 ImageProvider._createErrorHandlerAndKey.<anonymous closure> (package:flutter/src/painting/image_provider.dart:459:11)
I/flutter (11127): #15 ImageProvider._createErrorHandlerAndKey (package:flutter/src/painting/image_provider.dart:451:16)
I/flutter (11127): #16 ImageProvider.resolve (package:flutter/src/painting/image_provider.dart:329:5)
I/flutter (11127): #17 _ImageState._resolveImage (package:flutter/src/widgets/image.dart:1116:16)
I/flutter (11127): #18 _ImageState.didChangeDependencies (package:flutter/src/widgets/image.dart:1069:5)
I/flutter (11127): #19 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4705:12)
I/flutter (11127): #20 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4520:5)
I/flutter (11127): ... Normal element mounting (7 frames)
I/flutter (11127): #27 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
I/flutter (11127): #28 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5991:32)
I/flutter (11127): ... Normal element mounting (48 frames)
I/flutter (11127): #76 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
I/flutter (11127): #77 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
I/flutter (11127): #78 SliverMultiBoxAdaptorElement.updateChild (package:flutter/src/widgets/sliver.dart:1164:36)
I/flutter (11127): #79 SliverMultiBoxAdaptorElement.createChild.<anonymous closure> (package:flutter/src/widgets/sliver.dart:1149:20)
I/flutter (11127): #80 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2620:19)
I/flutter (11127): #81 SliverMultiBoxAdaptorElement.createChild (package:flutter/src/widgets/sliver.dart:1142:11)
I/flutter (11127): #82 RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure> (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:356:23)
I/flutter (11127): #83 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1868:58)
I/flutter (11127): #84 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:920:15)
I/flutter (11127): #85 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1868:13)
I/flutter (11127): #86 RenderSliverMultiBoxAdaptor._createOrObtainChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:345:5)
I/flutter (11127): #87 RenderSliverMultiBoxAdaptor.addInitialChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:429:5)
I/flutter (11127): #88 RenderSliverGrid.performLayout (package:flutter/src/rendering/sliver_grid.dart:549:12)
I/flutter (11127): #89 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #90 RenderSliverEdgeInsetsPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:137:11)
I/flutter (11127): #91 RenderSliverPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:377:11)
I/flutter (11127): #92 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #93 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:454:13)
I/flutter (11127): #94 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1445:12)
I/flutter (11127): #95 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1354:20)
I/flutter (11127): #96 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #97 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #98 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #99 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #100 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #101 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #102 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #103 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #104 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #105 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #106 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #107 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #108 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #109 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #110 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #111 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #112 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #113 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #114 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #115 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:173:11)
I/flutter (11127): #116 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:482:7)
I/flutter (11127): #117 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:242:7)
I/flutter (11127): #118 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:401:14)
I/flutter (11127): #119 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #120 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #121 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #122 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #123 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1269:11)
I/flutter (11127): #124 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #125 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #126 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #127 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #128 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #129 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #130 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #131 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #132 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #133 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #134 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #135 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #136 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #137 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #138 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #139 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #140 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3221:13)
I/flutter (11127): #141 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #142 _RenderTheatre.performLayout (package:flutter/src/widgets/overlay.dart:702:15)
I/flutter (11127): #143 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #144 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #145 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #146 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #147 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #148 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #149 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #150 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #151 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #152 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #153 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #154 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:115:13)
I/flutter (11127): #155 RenderObject.layout (package:flutter/src/rendering/object.dart:1769:7)
I/flutter (11127): #156 RenderView.performLayout (package:flutter/src/rendering/view.dart:169:13)
I/flutter (11127): #157 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (11127): #158 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:889:18)
I/flutter (11127): #159 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:404:19)
I/flutter (11127): #160 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:867:13)
I/flutter (11127): #161 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:286:5)
I/flutter (11127): #162 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1115:15)
I/flutter (11127): #163 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1054:9)
I/flutter (11127): #164 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:863:7)
I/flutter (11127): (elided 14 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
I/flutter (11127):
I/flutter (11127): Image provider: NetworkImage("p1", scale: 1.0)
I/flutter (11127): Image key: NetworkImage("p1", scale: 1.0)
I/flutter (11127): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (11127): Another exception was thrown: Invalid argument(s): No host specified in URI file:///p2
I/flutter (11127): Another exception was thrown: Invalid argument(s): No host specified in URI file:///p3
I/flutter (11127): Another exception was thrown: Invalid argument(s): No host specified in URI file:///p4
Base from the error that you're, it looks like the Image provider is trying to load "p1" as a NetworkImage. Though from the comments, it's likely that the parameters set in have been incorrectly set. Possibly the id has been switched with the imageUrl.
ProductItem(
loadedProducts[index].id,
loadedProducts[index].imageUrl,
loadedProducts[index].name,
);
I have a TabBar to switch between login and register, both of them are Stateful widgets.
When the Navigator is commented, there is no error. If Navigator is not commented the error mentioned below is thrown.
Providing relevant code below -
Login/Register Tab View
Flexible(
child: TabBarView(
children: [
Login(), // A Stateful Widget,
Register(),
],
),
),
Login Submit Button -
Padding(
padding: const EdgeInsets.only(top: 20.0),
child: MaterialButton(
color: Theme.of(context).accentColor,
textColor: Colors.white,
onPressed: loginPressed(context),
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Text('Login'),
),
),
),
function loginPressed() -
loginPressed(BuildContext context) {
//Will Be conditions here right now redirection for sake of testing
Navigator.pushReplacementNamed(context, 'home');
}
Error -
I/flutter ( 4421): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 4421): The following assertion was thrown building Login(dirty, dependencies: [_InheritedTheme,
I/flutter ( 4421): _LocalizationsScope-[GlobalKey#5872b]], state: _LoginState#6fe41):
I/flutter ( 4421): setState() or markNeedsBuild() called during build.
I/flutter ( 4421): This Overlay widget cannot be marked as needing to build because the framework is already in the
I/flutter ( 4421): process of building widgets. A widget can be marked as needing to be built during the build phase
I/flutter ( 4421): only if one of its ancestors is currently building. This exception is allowed because the framework
I/flutter ( 4421): builds parent widgets before children, which means a dirty descendant will always be built.
I/flutter ( 4421): Otherwise, the framework might not visit this widget during this build phase.
I/flutter ( 4421): The widget on which setState() or markNeedsBuild() was called was:
I/flutter ( 4421): Overlay-[LabeledGlobalKey<OverlayState>#e1e0c]
I/flutter ( 4421): The widget which was currently being built when the offending call was made was:
I/flutter ( 4421): Login
I/flutter ( 4421):
I/flutter ( 4421): The relevant error-causing widget was:
I/flutter ( 4421): Login file:///D:/flutter_projects/project/lib/screens/login_reg.dart:50:23
I/flutter ( 4421):
I/flutter ( 4421): When the exception was thrown, this was the stack:
I/flutter ( 4421): #0 Element.markNeedsBuild.<anonymous closure> (package:flutter/src/widgets/framework.dart:3896:11)
I/flutter ( 4421): #1 Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:3911:6)
I/flutter ( 4421): #2 State.setState (package:flutter/src/widgets/framework.dart:1168:14)
I/flutter ( 4421): #3 OverlayState.insertAll (package:flutter/src/widgets/overlay.dart:344:5)
I/flutter ( 4421): #4 OverlayRoute.install (package:flutter/src/widgets/routes.dart:44:24)
I/flutter ( 4421): #5 TransitionRoute.install (package:flutter/src/widgets/routes.dart:181:11)
I/flutter ( 4421): #6 ModalRoute.install (package:flutter/src/widgets/routes.dart:959:11)
I/flutter ( 4421): #7 NavigatorState.pushReplacement (package:flutter/src/widgets/navigator.dart:1883:14)
I/flutter ( 4421): #8 NavigatorState.pushReplacementNamed (package:flutter/src/widgets/navigator.dart:1710:12)
I/flutter ( 4421): #9 Navigator.pushReplacementNamed (package:flutter/src/widgets/navigator.dart:972:34)
I/flutter ( 4421): #10 _LoginState.loginPressed (package:project/screens/login.dart:72:15)
I/flutter ( 4421): #11 _LoginState.build (package:project/screens/login.dart:57:30)
I/flutter ( 4421): #12 StatefulElement.build (package:flutter/src/widgets/framework.dart:4334:27)
I/flutter ( 4421): #13 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4223:15)
I/flutter ( 4421): #14 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
I/flutter ( 4421): #15 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
I/flutter ( 4421): #16 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
I/flutter ( 4421): #17 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
I/flutter ( 4421): #18 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 4421): #19 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 4421): #20 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
I/flutter ( 4421): #21 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
I/flutter ( 4421): #22 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
I/flutter ( 4421): #23 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
I/flutter ( 4421): #24 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 4421): #25 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 4421): #26 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
I/flutter ( 4421): #27 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 4421): #28 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 4421): #29 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
I/flutter ( 4421): #30 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 4421): #31 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 4421): #32 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
I/flutter ( 4421): #33 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
I/flutter ( 4421): #34 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
I/flutter ( 4421): #35 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
I/flutter ( 4421): #36 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 4421): #37 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 4421): #38 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
I/flutter ( 4421): #39 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
I/flutter ( 4421): #40 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
I/flutter ( 4421): #41 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
I/flutter ( 4421): #42 ParentDataElement.mount (package:flutter/src/widgets/framework.dart:4617:11)
I/flutter ( 4421): #43 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 4421): #44 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 4421): #45 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
I/flutter ( 4421): #46 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
I/flutter ( 4421): #47 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
I/flutter ( 4421): #48 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
I/flutter ( 4421): #49 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
I/flutter ( 4421): #50 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 4421): #51 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 4421): #52 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
I/flutter ( 4421): #53 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
I/flutter ( 4421): #54 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
I/flutter ( 4421): #55 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
I/flutter ( 4421): #56 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter ( 4421): #57 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter ( 4421): #58 SliverMultiBoxAdaptorElement.updateChild (package:flutter/src/widgets/sliver.dart:1288:36)
I/flutter ( 4421): #59 SliverMultiBoxAdaptorElement.createChild.<anonymous closure> (package:flutter/src/widgets/sliver.dart:1273:20)
I/flutter ( 4421): #60 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2412:19)
I/flutter ( 4421): #61 SliverMultiBoxAdaptorElement.createChild (package:flutter/src/widgets/sliver.dart:1266:11)
I/flutter ( 4421): #62 RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure> (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:354:23)
I/flutter ( 4421): #63 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1823:58)
I/flutter ( 4421): #64 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:875:15)
I/flutter ( 4421): #65 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1823:13)
I/flutter ( 4421): #66 RenderSliverMultiBoxAdaptor._createOrObtainChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:343:5)
I/flutter ( 4421): #67 RenderSliverMultiBoxAdaptor.addInitialChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:427:5)
I/flutter ( 4421): #68 RenderSliverFixedExtentBoxAdaptor.performLayout (package:flutter/src/rendering/sliver_fixed_extent_list.dart:196:12)
I/flutter ( 4421): #69 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #70 RenderSliverEdgeInsetsPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:134:11)
I/flutter ( 4421): #71 _RenderSliverFractionalPadding.performLayout (package:flutter/src/widgets/sliver.dart:1165:11)
I/flutter ( 4421): #72 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #73 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:410:13)
I/flutter ( 4421): #74 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1367:12)
I/flutter ( 4421): #75 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1285:20)
I/flutter ( 4421): #76 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #77 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #78 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #79 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #80 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #81 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #82 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #83 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #84 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #85 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #86 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #87 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #88 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #89 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #90 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #91 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #92 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #93 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #94 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #95 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:806:17)
I/flutter ( 4421): #96 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #97 RenderPositionedBox.performLayout (package:flutter/src/rendering/shifted_box.dart:392:13)
I/flutter ( 4421): #98 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #99 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:163:11)
I/flutter ( 4421): #100 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:477:7)
I/flutter ( 4421): #101 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:232:7)
I/flutter ( 4421): #102 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:391:14)
I/flutter ( 4421): #103 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #104 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #105 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #106 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #107 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1232:11)
I/flutter ( 4421): #108 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #109 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:206:11)
I/flutter ( 4421): #110 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #111 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #112 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #113 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #114 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #115 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #116 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #117 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #118 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #119 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #120 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #121 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #122 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #123 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 4421): #124 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 4421): #125 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3166:14)
I/flutter ( 4421): #126 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following NoSuchMethodError was thrown building _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#09487](dirty, state: _OverlayEntryState#46afb):
The getter 'status' was called on null.
Receiver: null
Tried calling: status
The relevant error-causing widget was:
MaterialApp file:///D:/flutter_projects/project/lib/main.dart:36:12
When the exception was thrown, this was the stack:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 ModalRoute._buildModalBarrier (package:flutter/src/widgets/routes.dart:1305:27)
#2 _OverlayEntryState.build (package:flutter/src/widgets/overlay.dart:169:25)
#3 StatefulElement.build (package:flutter/src/widgets/framework.dart:4334:27)
#4 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4223:15)
...
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The method 'drive' was called on null.
Receiver: null
Tried calling: drive<Offset>(Instance of '_ChainedEvaluation<Offset>')
The relevant error-causing widget was:
MaterialApp file:///D:/flutter_projects/project/lib/main.dart:36:12
════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 4421): #127 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:505:15)
I/flutter ( 4421): #128 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1584:7)
I/flutter ( 4421): #129 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:844:18)
I/flutter ( 4421): #130 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:344:19)
I/flutter ( 4421): #131 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:774:13)
I/flutter ( 4421): #132 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:283:5)
I/flutter ( 4421): #133 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1102:15)
I/flutter ( 4421): #134 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1041:9)
I/flutter ( 4421): #135 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:957:5)
I/flutter ( 4421): #139 _invoke (dart:ui/hooks.dart:259:10)
I/flutter ( 4421): #140 _drawFrame (dart:ui/hooks.dart:217:3)
I/flutter ( 4421): (elided 3 frames from package dart:async)
I/flutter ( 4421):
I/flutter ( 4421): ════════════════════════════════════════════════════════════════════════════════════════════════════
Have no idea what has gone wrong.
In your widget building code, you are calling that loginPressed method.
Remember, when you write the following code:
loginPressed(context)
it's actually calling/executing that function. So, you are actually trying to navigate to another page while the current widget is still building. That's the reason why you are getting the exception.
You can fix it in 2 ways:
Method 1:
Change your onPressed code like:
onPressed: () {
loginPressed(context);
}
Method 2:
Pass the function reference (You don't need to pass the context, the function will already have access to that):
onPressed:loginPressed,
And change the function like:
loginPressed() {
Navigator.pushReplacementNamed(context, 'home');
}
Actually I am working on Login page with Bloc. So when I press submit button, it does business logic on bloc then trying to navigate to home page based on the result. I tried this
Widget submitButton() {
return StreamBuilder(
stream: bloc.submitStream,
builder: (context, snapshot) {
if (snapshot.data == "Success") {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => RegisterPage(),
),
);
}
return RaisedButton(
child: Text("Submit"),
onPressed: () {
bloc.submitSink.add(null);
},
);
},
);
}
But I got error like this The widget which was currently being built when the offending call was made....
Later then I found two solution:
1. Using SchedulerBinding,
2. Using WidgetsBinding. So what is the difference between SchedulerBinding and WidgetsBinding. Which one do I have to use?
Full Error Log:
I/flutter (17893): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (17893): The following assertion was thrown building LayoutBuilder:
I/flutter (17893): setState() or markNeedsBuild() called during build.
I/flutter (17893): This Overlay widget cannot be marked as needing to build because the framework is already in the
I/flutter (17893): process of building widgets. A widget can be marked as needing to be built during the build phase
I/flutter (17893): only if one of its ancestors is currently building. This exception is allowed because the framework
I/flutter (17893): builds parent widgets before children, which means a dirty descendant will always be built.
I/flutter (17893): Otherwise, the framework might not visit this widget during this build phase.
I/flutter (17893): The widget on which setState() or markNeedsBuild() was called was:
I/flutter (17893): Overlay-[LabeledGlobalKey<OverlayState>#70089](state: OverlayState#3bf13(entries:
I/flutter (17893): [OverlayEntry#9280a(opaque: false; maintainState: false), OverlayEntry#1af87(opaque: false;
I/flutter (17893): maintainState: true), OverlayEntry#9fb49(opaque: false; maintainState: false),
I/flutter (17893): OverlayEntry#87589(opaque: false; maintainState: true)]))
I/flutter (17893): The widget which was currently being built when the offending call was made was:
I/flutter (17893): LayoutBuilder(renderObject: _RenderLayoutBuilder#d3baf relayoutBoundary=up1 NEEDS-LAYOUT
I/flutter (17893): NEEDS-PAINT)
I/flutter (17893):
I/flutter (17893): When the exception was thrown, this was the stack:
I/flutter (17893): #0 Element.markNeedsBuild.<anonymous closure> (package:flutter/src/widgets/framework.dart:3497:11)
I/flutter (17893): #1 Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:3523:6)
I/flutter (17893): #2 State.setState (package:flutter/src/widgets/framework.dart:1138:14)
I/flutter (17893): #3 OverlayState.insertAll (package:flutter/src/widgets/overlay.dart:301:5)
I/flutter (17893): #4 OverlayRoute.install (package:flutter/src/widgets/routes.dart:43:24)
I/flutter (17893): #5 TransitionRoute.install (package:flutter/src/widgets/routes.dart:184:11)
I/flutter (17893): #6 ModalRoute.install (package:flutter/src/widgets/routes.dart:899:11)
I/flutter (17893): #7 NavigatorState.push (package:flutter/src/widgets/navigator.dart:1672:11)
I/flutter (17893): #8 Navigator.push (package:flutter/src/widgets/navigator.dart:1011:34)
I/flutter (17893): #9 _SetPinPageState.submitButton (package:technicalreport/screens/set_pin_page.dart:94:15)
I/flutter (17893): #10 _SetPinPageState.build.<anonymous closure>.<anonymous closure> (package:technicalreport/screens/set_pin_page.dart:52:29)
I/flutter (17893): #11 OrientationBuilder._buildWithConstraints (package:flutter/src/widgets/orientation_builder.dart:48:12)
I/flutter (17893): #12 _LayoutBuilderElement._layout.<anonymous closure> (package:flutter/src/widgets/layout_builder.dart:111:26)
I/flutter (17893): #13 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2253:19)
I/flutter (17893): #14 _LayoutBuilderElement._layout (package:flutter/src/widgets/layout_builder.dart:107:11)
I/flutter (17893): #15 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1728:58)
I/flutter (17893): #16 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:797:15)
I/flutter (17893): #17 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1728:13)
I/flutter (17893): #18 _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:205:5)
I/flutter (17893): #19 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #20 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11)
I/flutter (17893): #21 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:350:7)
I/flutter (17893): #22 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7)
I/flutter (17893): #23 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14)
I/flutter (17893): #24 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #25 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #26 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #27 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #28 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1206:11)
I/flutter (17893): #29 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #30 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #31 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #32 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #33 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #34 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #35 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #36 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #37 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #38 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #39 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #40 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #41 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #42 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #43 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #44 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #45 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3032:13)
I/flutter (17893): #46 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #47 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
I/flutter (17893): #48 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #49 __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #50 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #51 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #52 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #53 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #54 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #55 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #56 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #57 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #58 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #59 RenderView.performLayout (package:flutter/src/rendering/view.dart:151:13)
I/flutter (17893): #60 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1507:7)
I/flutter (17893): #61 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:766:18)
I/flutter (17893): #62 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:329:19)
I/flutter (17893): #63 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:701:13)
I/flutter (17893): #64 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:268:5)
I/flutter (17893): #65 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:988:15)
I/flutter (17893): #66 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:928:9)
I/flutter (17893): #67 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:749:7)
I/flutter (17893): #76 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
I/flutter (17893): #77 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
I/flutter (17893): #78 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter (17893): (elided 8 frames from package dart:async)
I/flutter (17893): ════════════════════════════════════════════════════════════════════════════════════════════════════
D/ (17893): HostConnection::get() New Host Connection established 0xa0ba6b40, tid 17931
D/EGL_emulation(17893): eglMakeCurrent: 0xa3508c40: ver 2 0 (tinfo 0x9084ab40)
There are three callbacks available in flutter which rendering flutter widgets.
Transient callbacks: triggered by the system’s [Window.onBeginFrame] callback, for synchronizing the application’s behavior to the system’s display. For example, [Ticker]s and [AnimationController]s trigger from these.
Persistent callbacks: triggered by the system’s [Window.onDrawFrame] callback, for updating the system’s display after transient callbacks have executed. For example, the rendering layer uses this to drive its rendering pipeline.
Post-frame callbacks: which are run after persistent callbacks, just before returning from the [Window.onDrawFrame] callback. * Non-rendering tasks, to be run between frames. These are given a priority and are executed in priority order according to a schedulingStrategy.
All above callbacks run sequentially, but for us, the last callback would work i.e Post-frame callbacks
Widgets Binding: The glue between the widgets layer and the Flutter engine. which comes with WidgetsBindingObserver mixin which has many callbacks but one which required to use is didChangeAppLifecycleState that returns AppLifecycleState.
Scheduler Binding: This is also similar to WidgetBinding but it does not provide any life cycle callbacks.
The below binding example would be called exactly the ones, means print statement like WidgetsBinding & SchedulerBinding will be printed only once as we called it initState(), but it will be called when build method finished it’s rendering.
void initState() {
super.initState();
print("initState");
WidgetsBinding.instance.addPostFrameCallback((_) {
print("WidgetsBinding");
});
SchedulerBinding.instance.addPostFrameCallback((_) {
print("SchedulerBinding");
});
}
Both solutions do the same.
WidgetsBinding inherits this Method from SchedulerBinding
https://api.flutter.dev/flutter/widgets/WidgetsBinding-mixin.html
It registers a callback that will be called after the frame is build.
See in the docs:
https://api.flutter.dev/flutter/scheduler/SchedulerBinding/addPostFrameCallback.html