I'm new to Flutter,
Right after creating my second app:
flutter create myapp && cd myapp && flutter run
I'm getting this exception. And although the app with the simple counter works in emulator, this exception doesn't look healthy, right?
Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode...
I/flutter ( 6000): ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 6000): The following assertion was thrown during a scheduler callback:
I/flutter ( 6000): There are multiple heroes that share the same tag within a subtree.
I/flutter ( 6000): Within each subtree for which heroes are to be animated (i.e. a PageRoute subtree), each Hero must
I/flutter ( 6000): have a unique non-null tag.
I/flutter ( 6000): In this case, multiple heroes had the following tag: <default FloatingActionButton tag>
...
(package:flutter/src/scheduler/binding.dart:1102:15)
I/flutter ( 6000): #141 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1049:9)
I/flutter ( 6000): #142 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:957:5)
I/flutter ( 6000): #146 _invoke (dart:ui/hooks.dart:259:10)
I/flutter ( 6000): #147 _drawFrame (dart:ui/hooks.dart:217:3)
I/flutter ( 6000): (elided 3 frames from package dart:async)
I/flutter ( 6000): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 6000): ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
I/flutter ( 6000): The following NetworkImageLoadException was thrown resolving an image codec:
I/flutter ( 6000): HTTP request failed, statusCode: 403,
I/flutter ( 6000): https://cdn.pixabay.com/photo/2016/04/10/21/34/woman-1320810_960_720.jpg
I/flutter ( 6000):
I/flutter ( 6000): When the exception was thrown, this was the stack:
I/flutter ( 6000): #0 NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:90:9)
I/flutter ( 6000): <asynchronous suspension>
I/flutter ( 6000): #1 NetworkImage.load (package:flutter/src/painting/_network_image_io.dart:47:14)
I/flutter ( 6000): #2 ImageProvider.resolve.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:flutter/src/painting/image_provider.dart:327:17)
I/flutter ( 6000): #3 ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:160:22)
...
(package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 6000): #213 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 6000): #214 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 6000): #215 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 6000): #216 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 6000): #217 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 6000): #218 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 6000): #219 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 6000): #220 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 6000): #221 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:163:11)
I/flutter ( 6000): #222 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:477:7)
I/flutter ( 6000): #223 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:232:7)
I/flutter ( 6000): #224 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:391:14)
I/flutter ( 6000): #225 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1584:7)
I/flutter ( 6000): #226 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:844:18)
I/flutter ( 6000): #227 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:344:19)
I/flutter ( 6000): #228 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:774:13)
I/flutter ( 6000): #229 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:283:5)
I/flutter ( 6000): #230 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1102:15)
I/flutter ( 6000): #231 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1041:9)
I/flutter ( 6000): #232 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:957:5)
I/flutter ( 6000): #236 _invoke (dart:ui/hooks.dart:259:10)
I/flutter ( 6000): #237 _drawFrame (dart:ui/hooks.dart:217:3)
I/flutter ( 6000): (elided 6 frames from package dart:async)
I/flutter ( 6000):
I/flutter ( 6000): Image provider:
I/flutter ( 6000): NetworkImage("https://cdn.pixabay.com/photo/2016/04/10/21/34/woman-1320810_960_720.jpg", scale:
I/flutter ( 6000): 1.0)
I/flutter ( 6000): Image key: NetworkImage("https://cdn.pixabay.com/photo/2016/04/10/21/34/woman-1320810_960_720.jpg",
I/flutter ( 6000): scale: 1.0)
I/flutter ( 6000): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 6000): Another exception was thrown: There are multiple heroes that share the same tag within a subtree.
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 26.5s
✓ Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk... 8.8s
Syncing files to device Android SDK built for x86...
10,951ms (!)
Do you have any idea why? Thanks!
The starter Flutter app doesn't contain things like loading network images as it's just a simple counter app. As Vijaya said, it's probably just an old error from another project. I get the same stuff when I use flutter run. Unless you edited the flutter create template, you have nothing to worry about.
Related
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');
}
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 upgraded flutter and and run my app, but it won't start and throws invalid arguments error.
I tried switching from dev and master channels and run flutter doctor on the terminal, but problem persists.
Running "flutter pub get" in feedback... 1.0s
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
Built build\app\outputs\apk\debug\app-debug.apk.
Installing build\app\outputs\apk\app.apk...
Syncing files to device Android SDK built for x86...
I/flutter ( 6956): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 6956): The following ArgumentError was thrown attaching to the render tree:
I/flutter ( 6956): Invalid argument(s)
I/flutter ( 6956): When the exception was thrown, this was the stack:
I/flutter ( 6956): #0 _StringBase.+ (dart:core-patch/string_patch.dart:260:57)
I/flutter ( 6956): #1 new _MainModel&Model&AuthModel&ResponsesModel (package:Feedback/scoped-models/main.dart:10:57)
I/flutter ( 6956): #2 new _MainModel&Model&AuthModel&ResponsesModel&UtilityModel (package:Feedback/scoped-models/main.dart)
I/flutter ( 6956): #3 new _MainModel&Model&AuthModel&ResponsesModel&UtilityModel&InternetModel (package:Feedback/scoped-models/main.dart)
I/flutter ( 6956): #4 new MainModel (package:Feedback/scoped-models/main.dart)
I/flutter ( 6956): #5 new MyAppState (package:Feedback/main.dart:23:27)
I/flutter ( 6956): #6 MyApp.createState (package:Feedback/main.dart:18:12)
I/flutter ( 6956): #7 new StatefulElement (package:flutter/src/widgets/framework.dart:3989:25)
I/flutter ( 6956): #8 StatefulWidget.createElement (package:flutter/src/widgets/framework.dart:802:38)
I/flutter ( 6956): #9 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3082:40)
I/flutter ( 6956): #10 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
I/flutter ( 6956): #11 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:939:16)
I/flutter ( 6956): #12 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:910:5)
I/flutter ( 6956): #13 RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:856:17)
I/flutter ( 6956): #14 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2320:19)
I/flutter ( 6956): #15 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:855:13)
I/flutter ( 6956): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:736:7)
I/flutter ( 6956): #17 runApp (package:flutter/src/widgets/binding.dart:786:7)
I/flutter ( 6956): #18 main (package:Feedback/main.dart:12:16)
I/flutter ( 6956): #19 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:216:25)
I/flutter ( 6956): #24 _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:208:5)
I/flutter ( 6956): #25 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
I/flutter ( 6956): #26 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
I/flutter ( 6956): (elided 4 frames from package dart:async)
I/flutter ( 6956): ════════════════════════════════════════════════════════════════════════════════════════════════════
D/EGL_emulation( 6956): eglMakeCurrent: 0xaa442fc0: ver 3 0 (tinfo 0x9fb5e310)
As what have previously pointed out in the comments, running flutter clean has been suggested because it usually solves build issues. The command clears the build cache of the project and trying to run the app again should rebuild the project and potentially clears out any issues. But in this case, it seems that you've found the cause is something else.
Going forward, it will also be helpful to provide a minimal repro for folks to be able to replicate the given issue.
I have a splash screen and a StreamBuilder that emits a state that contains information about authentication status. When the authentication status is known, I want to navigate either to sign in page or home page. But when I write something like Navigator.of(context).pushReplacement(...) I get
I/flutter ( 2058): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 2058): The following assertion was thrown building StreamBuilder(dirty, state:
I/flutter ( 2058): _StreamBuilderBaseState>#f4346):
I/flutter ( 2058): setState() or markNeedsBuild() called during build.
I/flutter ( 2058): This Overlay widget cannot be marked as needing to build because the framework is already in the
I/flutter ( 2058): process of building widgets. A widget can be marked as needing to be built during the build phase
I/flutter ( 2058): only if one of its ancestors is currently building. This exception is allowed because the framework
I/flutter ( 2058): builds parent widgets before children, which means a dirty descendant will always be built.
I/flutter ( 2058): Otherwise, the framework might not visit this widget during this build phase.
I/flutter ( 2058): The widget on which setState() or markNeedsBuild() was called was:
I/flutter ( 2058): Overlay-[LabeledGlobalKey#e0460](state: OverlayState#ab1a5(entries:
I/flutter ( 2058): [OverlayEntry#4e962(opaque: false; maintainState: false), OverlayEntry#7656a(opaque: false;
I/flutter ( 2058): maintainState: true), OverlayEntry#1f86e(opaque: false; maintainState: false),
I/flutter ( 2058): OverlayEntry#05a15(opaque: false; maintainState: true)]))
I/flutter ( 2058): The widget which was currently being built when the offending call was made was:
I/flutter ( 2058): StreamBuilder(dirty, state: _StreamBuilderBaseState>#f4346)
I/flutter ( 2058):
I/flutter ( 2058): When the exception was thrown, this was the stack:
I/flutter ( 2058): #0 Element.markNeedsBuild. (package:flutter/src/widgets/framework.dart:3503:11)
I/flutter ( 2058): #1 Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:3529:6)
I/flutter ( 2058): #2 State.setState (package:flutter/src/widgets/framework.dart:1133:14)
I/flutter ( 2058): #3 OverlayState.insertAll (package:flutter/src/widgets/overlay.dart:346:5)
I/flutter ( 2058): #4 OverlayRoute.install (package:flutter/src/widgets/routes.dart:43:24)
I/flutter ( 2058): #5 TransitionRoute.install (package:flutter/src/widgets/routes.dart:180:11)
I/flutter ( 2058): #6 ModalRoute.install (package:flutter/src/widgets/routes.dart:895:11)
I/flutter ( 2058): #7 NavigatorState.pushReplacement (package:flutter/src/widgets/navigator.dart:1799:14)
I/flutter ( 2058): #8 _replace (package:map_chat/application/navigation.dart:75:27)
I/flutter ( 2058): #9 _SignInPage.replace (package:map_chat/application/navigation.dart:67:5)
I/flutter ( 2058): #10 Roadmap.replace (package:map_chat/application/navigation.dart:25:18)
I/flutter ( 2058): #11 _SplashPageState._buildPageBasedOnAuthenticationState (package:map_chat/feature/splash.dart:52:19)
I/flutter ( 2058): #12 _SplashPageState._buildSplashScreen (package:map_chat/feature/splash.dart:40:11)
I/flutter ( 2058): #13 _SplashPageState._buildPage. (package:map_chat/feature/splash.dart:27:18)
I/flutter ( 2058): #14 StreamBuilder.build (package:flutter/src/widgets/async.dart:425:74)
I/flutter ( 2058): #15 _StreamBuilderBaseState.build (package:flutter/src/widgets/async.dart:125:48)
I/flutter ( 2058): #16 StatefulElement.build (package:flutter/src/widgets/framework.dart:3825:27)
I/flutter ( 2058): #17 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3739:15)
I/flutter ( 2058): #18 Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter ( 2058): #19 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2278:33)
I/flutter ( 2058): #20 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:700:20)
I/flutter ( 2058): #21 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:286:5)
I/flutter ( 2058): #22 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1012:15)
I/flutter ( 2058): #23 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:952:9)
I/flutter ( 2058): #24 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame. (package:flutter/src/scheduler/binding.dart:773:7)
I/flutter ( 2058): #33 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)
I/flutter ( 2058): #34 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
I/flutter ( 2058): #35 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:171:12)
I/flutter ( 2058): (elided 8 frames from package dart:async and package dart:async-patch)
The only workaround I found is to schedule the navigation to the end of event queue using Future(...).then(navigate) but that's sick. Is here an adequate solution for this?
You can listen your stream outside of build method and redirect to another view from there.
---- EDITED ----
This is an example of how you can do that:
#override
void initState() {
super.initState();
Future.delayed(Duration.zero, _verify);
}
void _verify() {
final _myBloc = BlocProvider.getBloc<MyBloc>();
_myBloc.myStream.listen((data) {
// Redirect to another view, given your condition
if (data) {
Navigator.of(context).pushNamed("my-new-route");
}
});
}
Just remember to save the StreamSubscription object returned from listen method, so you can cancel the subscription on dispose().
I still not happy with my solution, but I use a
if(snapshot.hasdata && snapshot.data.navigate) {
Future.microtask(() => Navigator.of(context).push... );
}
My app is displaying lots of images, and some urls may not be valid.
This is the code i use to display the image:
(I use the cached_network_image plugin)
CachedNetworkImage(
imageUrl: images.first,
fit: BoxFit.cover,
placeholder: (context, url) => Center(
child: CircularProgressIndicator(),
),
errorWidget: (context, url, error) => Center(
child: const Icon(Icons.error)
)
)
Basically, there is the error that is thrown:
E/flutter (28425): [ERROR:flutter/lib/ui/painting/codec.cc(97)] Failed decoding image. Data is either invalid, or it is encoded using an unsupported format.
I/flutter (28425): ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
I/flutter (28425): The following _Exception was thrown resolving an image codec:
I/flutter (28425): Exception: operation failed
I/flutter (28425):
I/flutter (28425): When the exception was thrown, this was the stack:
I/flutter (28425): #0 FileImage._loadAsync (package:flutter/src/painting/image_provider.dart:564:12)
I/flutter (28425): <asynchronous suspension>
I/flutter (28425): #1 FileImage.load (package:flutter/src/painting/image_provider.dart:549:14)
I/flutter (28425): #2 ImageProvider.resolve.<anonymous closure>.<anonymous closure> (package:flutter/src/painting/image_provider.dart:285:105)
I/flutter (28425): #3 ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:157:22)
I/flutter (28425): #4 ImageProvider.resolve.<anonymous closure> (package:flutter/src/painting/image_provider.dart:285:82)
I/flutter (28425): #5 SynchronousFuture.then (package:flutter/src/foundation/synchronous_future.dart:38:29)
I/flutter (28425): #6 ImageProvider.resolve (package:flutter/src/painting/image_provider.dart:283:30)
I/flutter (28425): #7 _ImageState._resolveImage (package:flutter/src/widgets/image.dart:631:20)
I/flutter (28425): #8 _ImageState.didChangeDependencies (package:flutter/src/widgets/image.dart:606:5)
I/flutter (28425): #9 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3862:12)
I/flutter (28425): #10 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3711:5)
I/flutter (28425): #11 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2956:14)
I/flutter (28425): #12 Element.updateChild (package:flutter/src/widgets/framework.dart:2759:12)
I/flutter (28425): #13 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter (28425): #14 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter (28425): #15 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4601:32)
I/flutter (28425): #16 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4992:17)
I/flutter (28425): #17 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter (28425): #18 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter (28425): #19 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter (28425): #20 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2273:33)
I/flutter (28425): #21 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:700:20)
I/flutter (28425): #22 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:268:5)
I/flutter (28425): #23 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:988:15)
I/flutter (28425): #24 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:928:9)
I/flutter (28425): #25 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:840:5)
I/flutter (28425): #29 _invoke (dart:ui/hooks.dart:209:10)
I/flutter (28425): #30 _drawFrame (dart:ui/hooks.dart:168:3)
I/flutter (28425): (elided 3 frames from package dart:async)
I/flutter (28425):
I/flutter (28425): Path:
I/flutter (28425): /data/user/0/xx.xxxx.xxxxxxxxxxx/cache/libCachedImageData/31c76660-5970-11e9-b769-3943ba44d1cb.html;
I/flutter (28425): charset=UTF-8
I/flutter (28425): ════════════════════════════════════════════════════════════════════════════════════════════════════
Notice that this url give some html... so that's normal
As I do not found any way to handle that error, i tried to use NetworkImageWithRetry from flutter_image package using:
FadeInImage(
placeholder: MemoryImage(kTransparentImage),
image: NetworkImageWithRetry(
imageUrl
),
fit: BoxFit.cover,
fadeInDuration: Duration(milliseconds: 150)
)
There is example of error that is thrown this time:
[ERROR:flutter/lib/ui/painting/codec.cc(97)] Failed decoding image. Data is either invalid, or it is encoded using an unsupported format.
I/flutter (31334): ══╡ EXCEPTION CAUGHT BY PACKAGE:FLUTTER_IMAGE ╞═════════════════════════════════════════════════════
I/flutter (31334): The following FetchFailure was thrown NetworkImageWithRetry failed to load
I/flutter (31334): xxxxxxxxxxxxxxxx :
I/flutter (31334): FetchFailure(
I/flutter (31334): attemptCount: 1
I/flutter (31334): httpStatusCode: null
I/flutter (31334): totalDuration: 0:00:05.969844
I/flutter (31334): originalException: Exception: operation failed
I/flutter (31334): )
I/flutter (31334): ════════════════════════════════════════════════════════════════════════════════════════════════════
This url send html...
The problem is that in release mode, I force close the app in case of any error, so i need to handle them
how can I just handle this types of error ?