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');
}
Related
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,
);
So I am using the Provider Package in my Flutter app and everything is going well until I closed my project in VSCode and reopened it with the same exact code and then I try to navigate to a new page using this method :
void _goToTheSettingsPage(BuildContext context) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => ChangeNotifierProvider.value(
value: SettingsProvider(),
child: SettingsPage(),
),
),
);
}
and the SettingsPage is code is very simple :
class SettingsPage extends StatelessWidget {
#override
Widget build(BuildContext context) {
AppLocalizations appLocalizations = AppLocalizations.of(context);
BibleDatabase bibleDatabase = Provider.of<BibleDatabase>(context);
SettingsProvider settingsProvider = Provider.of<SettingsProvider>(context);
int selectedTool = Provider.of<int>(context);
Color selectedColor = HelperMethods.getColorFromNumber(selectedTool);
double screenWidth = MediaQuery.of(context).size.width;
return Scaffold(
// Normal UI Widgets Here
)
}
}
and those are the providers I have put in the start of the Material App :
[
StreamProvider<double>(
builder: (context) => bibleDatabase.preferredFontSizeController.stream,
),
StreamProvider<int>(
builder: (context) => bibleDatabase.selectedToolController.stream,
)
];
while bibleDatabase is just a value coming from a normal Provider.value() object...
so why I am getting this weird error??
I/flutter ( 8624): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 8624): The following NoSuchMethodError was thrown building SettingsPage(dirty, dependencies:
I/flutter ( 8624): [InheritedProvider<SettingsProvider>, _LocalizationsScope-[GlobalKey#d8deb], MediaQuery,
I/flutter ( 8624): InheritedProvider<BibleDatabase>, InheritedProvider<int>]):
I/flutter ( 8624): The method 'split' was called on null.
I/flutter ( 8624): Receiver: null
I/flutter ( 8624): Tried calling: split(".")
I/flutter ( 8624): User-created ancestor of the error-causing widget was:
I/flutter ( 8624): ChangeNotifierProvider<SettingsProvider>
I/flutter ( 8624):
lib\pages\bible_page.dart:75
I/flutter ( 8624): When the exception was thrown, this was the stack:
I/flutter ( 8624): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5)
I/flutter ( 8624): #1 AppLocalizations._resolve
package:easy_localization/easy_localization_delegate.dart:84
I/flutter ( 8624): #2 AppLocalizations.tr
package:easy_localization/easy_localization_delegate.dart:62
I/flutter ( 8624): #3 SettingsPage.build
package:christy/pages/settings_page.dart:48
I/flutter ( 8624): #4 StatelessElement.build
package:flutter/…/widgets/framework.dart:4001
I/flutter ( 8624): #5 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3933
I/flutter ( 8624): #6 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #7 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3916
I/flutter ( 8624): #8 ComponentElement.mount
package:flutter/…/widgets/framework.dart:3911
I/flutter ( 8624): #9 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #10 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #11 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #12 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #13 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3916
I/flutter ( 8624): #14 ComponentElement.mount
package:flutter/…/widgets/framework.dart:3911
I/flutter ( 8624): #15 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #16 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #17 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #18 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #19 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3916
I/flutter ( 8624): #20 StatefulElement._firstBuild
package:flutter/…/widgets/framework.dart:4080
I/flutter ( 8624): #21 ComponentElement.mount
package:flutter/…/widgets/framework.dart:3911
I/flutter ( 8624): #22 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #23 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #24 SingleChildRenderObjectElement.mount
package:flutter/…/widgets/framework.dart:5119
I/flutter ( 8624): #25 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #26 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #27 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #28 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #29 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3916
I/flutter ( 8624): #30 ComponentElement.mount
package:flutter/…/widgets/framework.dart:3911
I/flutter ( 8624): #31 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #32 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #33 SingleChildRenderObjectElement.mount
package:flutter/…/widgets/framework.dart:5119
I/flutter ( 8624): #34 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #35 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #36 SingleChildRenderObjectElement.mount
package:flutter/…/widgets/framework.dart:5119
I/flutter ( 8624): #37 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #38 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #39 SingleChildRenderObjectElement.mount
package:flutter/…/widgets/framework.dart:5119
I/flutter ( 8624): #40 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #41 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #42 SingleChildRenderObjectElement.mount
package:flutter/…/widgets/framework.dart:5119
I/flutter ( 8624): #43 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #44 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #45 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #46 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #47 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3916
I/flutter ( 8624): #48 StatefulElement._firstBuild
package:flutter/…/widgets/framework.dart:4080
I/flutter ( 8624): #49 ComponentElement.mount
package:flutter/…/widgets/framework.dart:3911
I/flutter ( 8624): #50 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #51 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #52 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #53 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #54 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3916
I/flutter ( 8624): #55 ComponentElement.mount
package:flutter/…/widgets/framework.dart:3911
I/flutter ( 8624): #56 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #57 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #58 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #59 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #60 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3916
I/flutter ( 8624): #68 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #69 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #70 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3916
I/flutter ( 8624): #71 ComponentElement.mount
package:flutter/…/widgets/framework.dart:3911
I/flutter ( 8624): #72 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #73 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #74 SingleChildRenderObjectElement.mount
package:flutter/…/widgets/framework.dart:5119
I/flutter ( 8624): #75 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #76 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #77 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #78 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #79 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3916
I/flutter ( 8624): #80 StatefulElement._firstBuild
package:flutter/…/widgets/framework.dart:4080
I/flutter ( 8624): #81 ComponentElement.mount
package:flutter/…/widgets/framework.dart:3911
I/flutter ( 8624): #82 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #83 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #84 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #92 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #93 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #94 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #95 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3916
I/flutter ( 8624): #96 ComponentElement.mount
package:flutter/…/widgets/framework.dart:3911
I/flutter ( 8624): #97 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #98 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #99 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #100 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #101 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3916
I/flutter ( 8624): #102 StatefulElement._firstBuild
package:flutter/…/widgets/framework.dart:4080
I/flutter ( 8624): #103 ComponentElement.mount
package:flutter/…/widgets/framework.dart:3911
I/flutter ( 8624): #104 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #105 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #106 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #107 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #108 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:3916
I/flutter ( 8624): #109 StatefulElement._firstBuild
package:flutter/…/widgets/framework.dart:4080
I/flutter ( 8624): #110 ComponentElement.mount
package:flutter/…/widgets/framework.dart:3911
I/flutter ( 8624): #111 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3093
I/flutter ( 8624): #112 Element.updateChild
package:flutter/…/widgets/framework.dart:2896
I/flutter ( 8624): #113 RenderObjectElement.updateChildren
package:flutter/…/widgets/framework.dart:4902
I/flutter ( 8624): #114 MultiChildRenderObjectElement.update
package:flutter/…/widgets/framework.dart:5235
I/flutter ( 8624): #115 Element.updateChild
package:flutter/…/widgets/framework.dart:2885
I/flutter ( 8624): #116 _TheatreElement.update
package:flutter/…/widgets/overlay.dart:607
I/flutter ( 8624): #117 Element.updateChild
package:flutter/…/widgets/framework.dart:2885
I/flutter ( 8624): #118 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #119 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #120 StatefulElement.update
package:flutter/…/widgets/framework.dart:4112
I/flutter ( 8624): #121 Element.updateChild
package:flutter/…/widgets/framework.dart:2885
I/flutter ( 8624): #122 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #123 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #124 ProxyElement.update
package:flutter/…/widgets/framework.dart:4246
I/flutter ( 8624): #125 _InheritedNotifierElement.update
package:flutter/…/widgets/inherited_notifier.dart:94
I/flutter ( 8624): #126 Element.updateChild
package:flutter/…/widgets/framework.dart:2885
I/flutter ( 8624): #127 SingleChildRenderObjectElement.update
package:flutter/…/widgets/framework.dart:5126
I/flutter ( 8624): #128 Element.updateChild
package:flutter/…/widgets/framework.dart:2885
I/flutter ( 8624): #129 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #130 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #131 StatefulElement.update
package:flutter/…/widgets/framework.dart:4112
I/flutter ( 8624): #132 Element.updateChild
package:flutter/…/widgets/framework.dart:2885
I/flutter ( 8624): #133 SingleChildRenderObjectElement.update
package:flutter/…/widgets/framework.dart:5126
I/flutter ( 8624): #134 Element.updateChild
package:flutter/…/widgets/framework.dart:2885
I/flutter ( 8624): #135 SingleChildRenderObjectElement.update
package:flutter/…/widgets/framework.dart:5126
I/flutter ( 8624): #136 Element.updateChild
package:flutter/…/widgets/framework.dart:2885
I/flutter ( 8624): #137 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:3953
I/flutter ( 8624): #138 Element.rebuild
package:flutter/…/widgets/framework.dart:3730
I/flutter ( 8624): #139 BuildOwner.buildScope
package:flutter/…/widgets/framework.dart:2340
I/flutter ( 8624): #140 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame
package:flutter/…/widgets/binding.dart:701
I/flutter ( 8624): #141 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback
package:flutter/…/rendering/binding.dart:285
I/flutter ( 8624): #142 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback
package:flutter/…/scheduler/binding.dart:1033
I/flutter ( 8624): #143 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame
package:flutter/…/scheduler/binding.dart:975
I/flutter ( 8624): #144 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame
package:flutter/…/scheduler/binding.dart:891
I/flutter ( 8624): #148 _invoke (dart:ui/hooks.dart:236:10)
I/flutter ( 8624): #149 _drawFrame (dart:ui/hooks.dart:194:3)
I/flutter ( 8624): (elided 3 frames from package dart:async)
I/flutter ( 8624): ════════════════════════════════════════════════════════════════════════════════════════════════════
I recently encountered this error. This error is because of Navigation. When you use Navigator.of(context).push then navigating page will become the child of the Material app and it will have no longer access to Provider.
See this Example::
Widget Tree before navigation
if you see this I am having MaterialApp and to that, I am children of Provider of AuthRouter. I wanted AuthRouter to be available to the entire Tree.
When I Navigate from StudentHomePage the widget tree will become like this
Widget Tree before navigation
If you see My AuthRouter is no Longer a Child of the MaterialApp. So StudentDashboardPage is a new child and it doesn't have access to AuthRouter. so when I try to access AuthRouter from StudentDashboardPage It will show an error.
Solution 1:: Pass the provider objects to SettingsPage i.e dependency injection.
I hope it will work for you.
Solution 2:: Wrap Provider on top of MaterialApp
I know there are quite a few questions that have a resembling title of NoSuchMethodError: The method '#**something**#' was called on null. And usually this issue happens when you try to access a null object's method. But, in my case this Exception is shown when I try to add the following code to my StatefulWidget:
_handleMyBusinessesTap() {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => PageBusinessList(
firebaseUser: widget.firebaseUser,
),
),
);
}
Once I try to use the Navigator object in my code I'm getting this exception.
The only difference I can think of that I have in this page from the other pages in which Navigator object does not causes any issues is that I build my page this way:
Widget build(BuildContext context) {
return DefaultTabController(
length: 3,
child: Scaffold(
appBar: _buildAppBar(),
drawer: _buildDrawer(),
body: _buildBody(),
),
);
}
I'm using here DefaultTabController contains a body of 3 page:
Widget _buildBody() {
return TabBarView(
children: [
MyCardScreen(),
ReceivedScreen(),
SentScreen(),
],
);
}
The _handleMyBusinessesTap method is one of the options I have in the drawer which I want to take me to a new page, but for some reason once I add it it throws this exception in the title. Does someone encountered this problem and know how it should be handled?
here is the buildDrawer method:
Widget _buildDrawer() {
return Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
UserAccountsDrawerHeader(
accountName: _buildAccountNameWidget(),
accountEmail: _buildAccountEmailWidget(),
currentAccountPicture: _buildAccountCircleAvatar(),
),
ListTile(title: Text("My Default Business Card"), onTap: _handleMyDefaultBusinessCardTap()),
ListTile(title: Text("My Businesses"), onTap: _handleMyBusinessesTap()),
ListTile(title: Text("Terms and Conditions"), onTap: _handleTermsAndConditionsTap()),
ListTile(title: Text("Privacy Policy"), onTap: _handlePrivacyPolicyTap()),
ListTile(title: Text("Log Out"), onTap: _handleLogOutTap()),
],
),
);
}
here is there rest of the stack:
I/flutter ( 722): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 722): The following assertion was thrown building PageMain(dirty, dependencies: [_InheritedTheme,
I/flutter ( 722): _LocalizationsScope-[GlobalKey#b039d]], state: _PageMainWidgetState#e33af):
I/flutter ( 722): setState() or markNeedsBuild() called during build.
I/flutter ( 722): This Overlay widget cannot be marked as needing to build because the framework is already in the
I/flutter ( 722): process of building widgets. A widget can be marked as needing to be built during the build phase
I/flutter ( 722): only if one of its ancestors is currently building. This exception is allowed because the framework
I/flutter ( 722): builds parent widgets before children, which means a dirty descendant will always be built.
I/flutter ( 722): Otherwise, the framework might not visit this widget during this build phase.
I/flutter ( 722): The widget on which setState() or markNeedsBuild() was called was:
I/flutter ( 722): Overlay-[LabeledGlobalKey<OverlayState>#51a6b](state: OverlayState#7d0ac(entries:
I/flutter ( 722): [OverlayEntry#f42cb(opaque: false; maintainState: false), OverlayEntry#d6b18(opaque: false;
I/flutter ( 722): maintainState: true), OverlayEntry#75d78(opaque: false; maintainState: false),
I/flutter ( 722): OverlayEntry#02406(opaque: false; maintainState: true), OverlayEntry#8f4e5(opaque: false;
I/flutter ( 722): maintainState: false), OverlayEntry#11c40(opaque: false; maintainState: true)]))
I/flutter ( 722): The widget which was currently being built when the offending call was made was:
I/flutter ( 722): PageMain(dirty, dependencies: [_InheritedTheme, _LocalizationsScope-[GlobalKey#b039d]], state:
I/flutter ( 722): _PageMainWidgetState#e33af)
I/flutter ( 722): When the exception was thrown, this was the stack:
I/flutter ( 722): #0 Element.markNeedsBuild.<anonymous closure> (package:flutter/src/widgets/framework.dart:3503:11)
I/flutter ( 722): #1 Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:3529:6)
I/flutter ( 722): #2 State.setState (package:flutter/src/widgets/framework.dart:1133:14)
I/flutter ( 722): #3 OverlayState.insertAll (package:flutter/src/widgets/overlay.dart:346:5)
I/flutter ( 722): #4 OverlayRoute.install (package:flutter/src/widgets/routes.dart:43:24)
I/flutter ( 722): #5 TransitionRoute.install (package:flutter/src/widgets/routes.dart:180:11)
I/flutter ( 722): #6 ModalRoute.install (package:flutter/src/widgets/routes.dart:895:11)
I/flutter ( 722): #7 NavigatorState.push (package:flutter/src/widgets/navigator.dart:1742:11)
I/flutter ( 722): #8 _PageMainWidgetState._handleMyBusinessesTap (package:bizooc_client/pages/page_main.dart:86:27)
I/flutter ( 722): #9 _PageMainWidgetState._buildDrawer (package:bizooc_client/pages/page_main.dart:60:57)
I/flutter ( 722): #10 _PageMainWidgetState.build (package:bizooc_client/pages/page_main.dart:33:17)
I/flutter ( 722): #11 StatefulElement.build (package:flutter/src/widgets/framework.dart:3825:27)
I/flutter ( 722): #12 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3739:15)
I/flutter ( 722): #13 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 722): #14 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3722:5)
I/flutter ( 722): #15 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3864:11)
I/flutter ( 722): #16 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3717:5)
I/flutter ( 722): #17 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #18 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #19 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
I/flutter ( 722): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #22 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16)
I/flutter ( 722): #23 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 722): #24 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3722:5)
I/flutter ( 722): #25 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3717:5)
I/flutter ( 722): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #28 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
I/flutter ( 722): #29 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #30 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #31 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
I/flutter ( 722): #32 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #33 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #34 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
I/flutter ( 722): #35 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #36 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #37 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
I/flutter ( 722): #38 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #39 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #40 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16)
I/flutter ( 722): #41 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 722): #42 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3722:5)
I/flutter ( 722): #43 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3864:11)
I/flutter ( 722): #44 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3717:5)
I/flutter ( 722): #45 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #46 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #47 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16)
I/flutter ( 722): #48 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 722): #49 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3722:5)
I/flutter ( 722): #50 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3717:5)
I/flutter ( 722): #51 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #52 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #53 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16)
I/flutter ( 722): #54 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 722): #55 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3722:5)
I/flutter ( 722): #56 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3864:11)
I/flutter ( 722): #57 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3717:5)
I/flutter ( 722): #58 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #59 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #60 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
I/flutter ( 722): #61 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #62 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #63 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16)
I/flutter ( 722): #64 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 722): #65 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3722:5)
I/flutter ( 722): #66 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3717:5)
I/flutter ( 722): #67 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #68 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #69 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
I/flutter ( 722): #70 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #71 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #72 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16)
I/flutter ( 722): #73 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 722): #74 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3722:5)
I/flutter ( 722): #75 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3864:11)
I/flutter ( 722): #76 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3717:5)
I/flutter ( 722): #77 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #78 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #79 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16)
I/flutter ( 722): #80 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 722): #81 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3722:5)
I/flutter ( 722): #82 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3717:5)
I/flutter ( 722): #83 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #84 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #85 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
I/flutter ( 722): #86 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #87 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #88 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16)
I/flutter ( 722): #89 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 722): #90 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3722:5)
I/flutter ( 722): #91 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3717:5)
I/flutter ( 722): #92 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #93 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #94 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16)
I/flutter ( 722): #95 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 722): #96 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3722:5)
I/flutter ( 722): #97 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3864:11)
I/flutter ( 722): #98 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3717:5)
I/flutter ( 722): #99 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #100 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #101 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16)
I/flutter ( 722): #102 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 722): #103 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3722:5)
I/flutter ( 722): #104 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3864:11)
I/flutter ( 722): #105 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3717:5)
I/flutter ( 722): #106 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2961:14)
I/flutter ( 722): #107 Element.updateChild (package:flutter/src/widgets/framework.dart:2764:12)
I/flutter ( 722): #108 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4659:32)
I/flutter ( 722): #109 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4992:17)
I/flutter ( 722): #110 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15)
I/flutter ( 722): #111 _TheatreElement.update (package:flutter/src/widgets/overlay.dart:607:16)
I/flutter ( 722): #112 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15)
I/flutter ( 722): #113 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16)
I/flutter ( 722): #114 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 722): #115 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 722): #116 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15)
I/flutter ( 722): #117 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16)
I/flutter ( 722): #118 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 722): #119 ProxyElement.update (package:flutter/src/widgets/framework.dart:4006:5)
I/flutter ( 722): #120 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15)
I/flutter ( 722): #121 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 722): #122 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15)
I/flutter ( 722): #123 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16)
I/flutter ( 722): #124 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 722): #125 StatefulElement.update (package:flutter/src/widgets/framework.dart:3894:5)
I/flutter ( 722): #126 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15)
I/flutter ( 722): #127 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 722): #128 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15)
I/flutter ( 722): #129 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter ( 722): #130 Element.updateChild (package:flutter/src/widgets/framework.dart:2753:15)
I/flutter ( 722): #131 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16)
I/flutter ( 722): #132 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 722): #133 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2278:33)
I/flutter ( 722): #134 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:700:20)
I/flutter ( 722): #135 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:286:5)
I/flutter ( 722): #136 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1012:15)
I/flutter ( 722): #137 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:952:9)
I/flutter ( 722): #138 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:864:5)
I/flutter ( 722): #142 _invoke (dart:ui/hooks.dart:219:10)
I/flutter ( 722): #143 _drawFrame (dart:ui/hooks.dart:178:3)
I/flutter ( 722): (elided 3 frames from package dart:async)
I/flutter ( 722): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 722): Another exception was thrown: NoSuchMethodError: The getter 'status' was called on null.
I/flutter ( 722): Another exception was thrown: NoSuchMethodError: The method 'drive' was called on null.
This is a common error when use callbacks functions.
ListTile(title: Text("Log Out"), onTap: _handleLogOutTap()),
To fix your issue you have some options :
1-
ListTile(title: Text("Log Out"), onTap: _handleLogOutTap),
2-
ListTile(title: Text("Log Out"), onTap: () => _handleLogOutTap()),
3-
ListTile(title: Text("Log Out"), onTap: () { _handleLogOutTap() ; }),
The same for all of your ListTile's.
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
I'm trying to find a solution to open a view after a delay in a loading view. I have a View, in which there is a button and when I press it, the onPressed() method triggers a Navigator.of(Context).pushNamed("/loading"). which opens the loading view. In the loading view I have then a function to make a delay of 1.5 sec and then open the home view, this is the code:
Future delay() async{
await new Future.delayed(new Duration(milliseconds: 1500), ()
{
Navigator.of(context).pushNamed("/home");
}
However, when the delay starts, after 1.5 sec, it opens the Home view, but with this exception:
I/flutter ( 5226): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 5226): The following assertion was thrown building IconTheme(color: Color(0xff000000)):
I/flutter ( 5226): Multiple widgets used the same GlobalKey.
I/flutter ( 5226): The key [LabeledGlobalKey<ScaffoldState>#a0051] was used by multiple widgets. The parents of those
I/flutter ( 5226): widgets were different widgets that both had the following description:
I/flutter ( 5226): IconTheme(color: Color(0xff000000))
I/flutter ( 5226): A GlobalKey can only be specified on one widget at a time in the widget tree.
I/flutter ( 5226): When the exception was thrown, this was the stack:
I/flutter ( 5226): #0 GlobalKey._debugReserveFor.<anonymous closure> (package:flutter/src/widgets/framework.dart:172:9)
I/flutter ( 5226): #1 GlobalKey._debugReserveFor (package:flutter/src/widgets/framework.dart:182:6)
I/flutter ( 5226): #2 Element.updateChild.<anonymous closure> (package:flutter/src/widgets/framework.dart:2649:13)
I/flutter ( 5226): #3 Element.updateChild (package:flutter/src/widgets/framework.dart:2652:6)
I/flutter ( 5226): #4 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #5 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #6 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #9 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #10 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #11 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #12 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #13 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #14 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #15 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #16 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #17 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #18 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #19 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #22 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #23 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #24 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #25 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #28 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #29 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #30 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #31 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #32 ParentDataElement.mount (package:flutter/src/widgets/framework.dart:3893:16)
I/flutter ( 5226): #33 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #34 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4693:32)
I/flutter ( 5226): #35 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #36 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #37 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #38 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #39 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #40 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #41 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #42 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #43 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #44 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #45 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #46 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3718:22)
I/flutter ( 5226): #47 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #48 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #49 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #50 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4588:14)
I/flutter ( 5226): #51 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #52 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #53 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #54 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #55 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #56 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #57 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #58 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #59 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4588:14)
I/flutter ( 5226): #60 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #61 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #62 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #63 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #64 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #65 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3718:22)
I/flutter ( 5226): #66 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #67 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #68 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #69 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #70 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #71 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #72 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3718:22)
I/flutter ( 5226): #73 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #74 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #75 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #76 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #77 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #78 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #79 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #80 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #81 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #82 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #83 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #84 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #85 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #86 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #87 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #88 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #89 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #90 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #91 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3718:22)
I/flutter ( 5226): #92 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #93 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #94 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #95 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #96 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #97 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #98 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3718:22)
I/flutter ( 5226): #99 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #100 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #101 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #102 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #103 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #104 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #105 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #106 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #107 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #108 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #109 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #110 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #111 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #112 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #113 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #114 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4588:14)
I/flutter ( 5226): #115 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #116 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #117 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4588:14)
I/flutter ( 5226): #118 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #119 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #120 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4588:14)
I/flutter ( 5226): #121 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #122 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #123 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #124 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #125 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #126 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3718:22)
I/flutter ( 5226): #127 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #128 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #129 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #130 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #131 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #132 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #133 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #134 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #135 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #136 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4588:14)
I/flutter ( 5226): #137 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #138 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #139 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4588:14)
I/flutter ( 5226): #140 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #141 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #142 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #143 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #144 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #145 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
E/flutter ( 5226): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter ( 5226): NoSuchMethodError: The method 'ancestorStateOfType' was called on null.
E/flutter ( 5226): Receiver: null
E/flutter ( 5226): Tried calling: ancestorStateOfType(Instance of 'TypeMatcher<NavigatorState>')
E/flutter ( 5226): #0 Object.noSuchMethod (dart:core-patch/dart:core/object_patch.dart:46)
E/flutter ( 5226): #1 Navigator.of (package:flutter/src/widgets/navigator.dart:722:19)
E/flutter ( 5226): #2 Navigator.pushReplacementNamed (package:flutter/src/widgets/navigator.dart:666:22)
E/flutter ( 5226): #3 switcher (package:ticketing/router.dart:53:13)
E/flutter ( 5226): #4 _LoadingViewState.switchView (/data/user/0/com.tiziano.flutterapp.flutterapp2/cache/ticketing_remasteredAHSWSC/ticketing_remastered/lib/view/loadingview/LoadingView.dart:79:3)
E/flutter ( 5226): #5 _LoadingViewState.delay.<anonymous closure> (/data/user/0/com.tiziano.flutterapp.flutterapp2/cache/ticketing_remasteredAHSWSC/ticketing_remastered/lib/view/loadingview/LoadingView.dart:74:70)
E/flutter ( 5226): #6 new Future.delayed.<anonymous closure> (dart:async/future.dart:310)
E/flutter ( 5226): #7 Timer._createTimer.<anonymous closure> (dart:async-patch/dart:async/timer_patch.dart:21)
E/flutter ( 5226): #8 _Timer._runTimers (dart:isolate-patch/dart:isolate/timer_impl.dart:367)
E/flutter ( 5226): #9 _Timer._handleMessage (dart:isolate-patch/dart:isolate/timer_impl.dart:401)
E/flutter ( 5226): #10 _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:164)
I/flutter ( 5226): #146 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #147 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #148 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4588:14)
I/flutter ( 5226): #149 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #150 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #151 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #152 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #153 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #154 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3718:22)
I/flutter ( 5226): #155 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #156 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #157 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #158 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #159 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #160 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #161 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3718:22)
I/flutter ( 5226): #162 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #163 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #164 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #165 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #166 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #167 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter ( 5226): #168 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3718:22)
I/flutter ( 5226): #169 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter ( 5226): #170 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter ( 5226): #171 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter ( 5226): #172 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4375:32)
I/flutter ( 5226): #173 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4703:17)
I/flutter ( 5226): #174 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter ( 5226): #175 _TheatreElement.update (package:flutter/src/widgets/overlay.dart:507:16)
I/flutter ( 5226): #176 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter ( 5226): #177 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #178 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #179 StatefulElement.update (package:flutter/src/widgets/framework.dart:3737:5)
I/flutter ( 5226): #180 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter ( 5226): #181 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #182 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #183 ProxyElement.update (package:flutter/src/widgets/framework.dart:3847:5)
I/flutter ( 5226): #184 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter ( 5226): #185 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4595:14)
I/flutter ( 5226): #186 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter ( 5226): #187 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #188 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #189 StatefulElement.update (package:flutter/src/widgets/framework.dart:3737:5)
I/flutter ( 5226): #190 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter ( 5226): #191 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4595:14)
I/flutter ( 5226): #192 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter ( 5226): #193 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4595:14)
I/flutter ( 5226): #194 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter ( 5226): #195 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter ( 5226): #196 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter ( 5226): #197 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2210:33)
I/flutter ( 5226): #198 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:621:20)
I/flutter ( 5226): #199 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:208:5)
I/flutter ( 5226): #200 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter ( 5226): #201 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter ( 5226): #202 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter ( 5226): #203 _invoke (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:120)
I/flutter ( 5226): #204 _drawFrame (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:109)
I/flutter ( 5226): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 5226): Another exception was thrown: Multiple widgets used the same GlobalKey.
By the way, in the Home View there aren't any black icons. (IconTheme(color: Color(0xff000000))
Can someone help?
You can do it in 2 ways:
Using Timer class.
import 'dart:async';
// Go to Page2 after 5s.
Timer(Duration(seconds: 5), () {
Navigator.push(context, MaterialPageRoute(builder: (_) => Screen2()));
});
Using Future.delayed class:
// Go to Page2 after 5s.
Future.delayed(Duration(seconds: 5), () {
Navigator.push(context, MaterialPageRoute(builder: (_) => Screen2()));
});
The benefit of using Timer over Future is its ability to cancel.
To open a view after some delay you can use Future.delayed:
Future.delayed(const Duration(milliseconds: 500), () {
setState(() {
// Here you can write your code for open new view
});
});
Use Future.delay constructor from dart:async library, the following code navigate from first page to second page after 3 seconds of clicking the RaisedButton, I do not understand why are you pushing a loading view ?
import 'dart:async';
class FirstView extends StatelessWidget {
#override
Widget build(BuildContext context) {
return new Scaffold(
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new Text("FIRST VIEW"),
new RaisedButton(
onPressed: () async {
await new Future.delayed(const Duration(seconds: 3));
Navigator.push(context, new MaterialPageRoute(builder: (__) => new SecondView()));
},
child: new Text("Go to 2nd view"),
)
],
),
),
);
}
}
class SecondView extends StatelessWidget {
#override
Widget build(BuildContext context) {
return new Scaffold(
body: new Center(
child: new Text("SECOND VIEW"),
),
);
}
}
You can use like this;
Future myFuture() async {
await new Future.delayed(new Duration(seconds: 3));
//return your_main_future_code_here;
}
ontab: () {
Future.delayed(Duration(seconds: 5), () {
Center(child: CircularProgressIndicator(color: kpurple));
Navigator.of(context).pushNamed('/Home');
});
},
not working circular progressIndicator
If you just want to delay code execution then you have to use await (it won't work without it)
print('Before delay: ${DateTime.now()}');
await Future.delayed(const Duration(milliseconds: 1500));
print('After delay: ${DateTime.now()}');