Flutter Camera Package: A resource failed to call release - flutter

I am currently working off of Flutter v 1.22.1(stable) and am running into an issue with the Camera package (v0.5.8+11). At first i thought it was an issue with the project itself and the HTTP requests that were being made.
I just tested it out again using the example provided on the Camera package page at https://pub.dev/packages/camera/example (exact copy and paste), and am receiving the message below after recording and then stopping after around 15-20 seconds (the main thing to note, is "A resource failed to call release"):
An Observatory debugger and profiler on Android SDK built for x86 64 is available at: http://[IP-Address]/gMHBybPacbQ=/
W/le.test_projec(15597): Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (light greylist, reflection)
I/ExoPlayerImpl(15597): Init a86fb73 [ExoPlayerLib/2.12.1] [generic_x86_64, Android SDK built for x86_64, Google, 28]
W/VideoCapabilities(15597): Unrecognized profile 4 for video/hevc
I/VideoCapabilities(15597): Unsupported profile 4 for video/mp4v-es
I/OMXClient(15597): IOmx service obtained
D/SurfaceUtils(15597): connecting to surface 0x73ead6b56010, reason connectToSurface
I/MediaCodec(15597): [OMX.google.h264.decoder] setting surface generation to 15971329
D/SurfaceUtils(15597): disconnecting from surface 0x73ead6b56010, reason connectToSurface(reconnect)
D/SurfaceUtils(15597): connecting to surface 0x73ead6b56010, reason connectToSurface(reconnect)
E/ACodec (15597): [OMX.google.h264.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010
I/ACodec (15597): codec does not support config priority (err -1010)
W/System (15597): A resource failed to call release.
I/chatty (15597): uid=10087(com.example.test_project) FinalizerDaemon identical 1 line
W/System (15597): A resource failed to call release.
I/OMXClient(15597): IOmx service obtained
I/ACodec (15597): codec does not support config priority (err -2147483648)
D/MediaCodec(15597): [OMX.google.h264.decoder] setting dataspace on output surface to #103
W/le.test_projec(15597): Accessing hidden method Landroid/media/AudioTrack$Builder;->setOffloadedPlayback(Z)Landroid/media/AudioTrack$Builder; (dark greylist, linking)
W/le.test_projec(15597): Accessing hidden method Landroid/media/AudioTrack$Builder;->setOffloadedPlayback(Z)Landroid/media/AudioTrack$Builder; (dark greylist, linking)
W/MapperHal(15597): buffer descriptor with invalid usage bits 0x2000
D/SoftwareRenderer(15597): setting dataspace on output surface to #103
W/MapperHal(15597): buffer descriptor with invalid usage bits 0x2000
W/MapperHal(15597): buffer descriptor with invalid usage bits 0x2000
W/System (15597): A resource failed to call release.
I/ExoPlayerImpl(15597): Init 9474624 [ExoPlayerLib/2.12.1] [generic_x86_64, Android SDK built for x86_64, Google, 28]
I/OMXClient(15597): IOmx service obtained
D/SurfaceUtils(15597): connecting to surface 0x73eadbff2010, reason connectToSurface
I/MediaCodec(15597): [OMX.google.h264.decoder] setting surface generation to 15971330
D/SurfaceUtils(15597): disconnecting from surface 0x73eadbff2010, reason connectToSurface(reconnect)
D/SurfaceUtils(15597): connecting to surface 0x73eadbff2010, reason connectToSurface(reconnect)
E/ACodec (15597): [OMX.google.h264.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010
I/ACodec (15597): codec does not support config priority (err -1010)
I/OMXClient(15597): IOmx service obtained
I/ACodec (15597): codec does not support config priority (err -2147483648)
D/MediaCodec(15597): [OMX.google.h264.decoder] setting dataspace on output surface to #103
W/MapperHal(15597): buffer descriptor with invalid usage bits 0x2000
D/SoftwareRenderer(15597): setting dataspace on output surface to #103
I/ExoPlayerImpl(15597): Release a86fb73 [ExoPlayerLib/2.12.1] [generic_x86_64, Android SDK built for x86_64, Google, 28] [goog.exo.core]
D/SurfaceUtils(15597): disconnecting from surface 0x73ead6b56010, reason disconnectFromSurface
W/MapperHal(15597): buffer descriptor with invalid usage bits 0x2000
I/flutter (15597): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (15597): The following assertion was thrown building Container(bg: BoxDecoration(border:
I/flutter (15597): Border.all(BorderSide(MaterialColor(primary value: Color(0xffe91e63)), 1.0, BorderStyle.solid)))):
I/flutter (15597): A VideoPlayerController was used after being disposed.
I/flutter (15597): Once you have called dispose() on a VideoPlayerController, it can no longer be used.
I/flutter (15597):
I/flutter (15597): The relevant error-causing widget was:
I/flutter (15597): Container file:///Users/giovanniconcepcion/Projects/test/test_project/lib/main.dart:168:27
I/flutter (15597):
I/flutter (15597): When the exception was thrown, this was the stack:
I/flutter (15597): #0 ChangeNotifier._debugAssertNotDisposed.<anonymous closure> (package:flutter/src/foundation/change_notifier.dart:117:9)
I/flutter (15597): #1 ChangeNotifier._debugAssertNotDisposed (package:flutter/src/foundation/change_notifier.dart:123:6)
I/flutter (15597): #2 ChangeNotifier.removeListener (package:flutter/src/foundation/change_notifier.dart:178:12)
I/flutter (15597): #3 _VideoPlayerState.didUpdateWidget (package:video_player/video_player.dart:612:26)
I/flutter (15597): #4 StatefulElement.update (package:flutter/src/widgets/framework.dart:4815:58)
I/flutter (15597): #5 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #6 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
I/flutter (15597): #7 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #8 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
I/flutter (15597): #9 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #10 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
I/flutter (15597): #11 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #12 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
I/flutter (15597): #13 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #14 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
I/flutter (15597): #15 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
I/flutter (15597): #16 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5)
I/flutter (15597): #17 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #18 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
I/flutter (15597): #19 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #20 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5647:32)
I/flutter (15597): #21 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6246:17)
I/flutter (15597): #22 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #23 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
I/flutter (15597): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #25 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
I/flutter (15597): #26 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
I/flutter (15597): #27 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5)
I/flutter (15597): #28 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #29 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5647:32)
I/flutter (15597): #30 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6246:17)
I/flutter (15597): #31 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #32 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
I/flutter (15597): #33 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #34 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5647:32)
I/flutter (15597): #35 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6246:17)
I/flutter (15597): #36 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #37 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
I/flutter (15597): #38 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
I/flutter (15597): #39 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5)
I/flutter (15597): #40 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #41 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
I/flutter (15597): #42 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
I/flutter (15597): #43 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5)
I/flutter (15597): #44 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #45 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
I/flutter (15597): #46 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
I/flutter (15597): #47 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5)
I/flutter (15597): #48 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #49 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5647:32)
I/flutter (15597): #50 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6246:17)
I/flutter (15597): #51 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #52 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
I/flutter (15597): #53 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
I/flutter (15597): #54 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
I/flutter (15597): #55 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
I/flutter (15597): #56 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #57 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
I/flutter (15597): #58 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
I/flutter (15597): #59 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5)
I/flutter (15597): #60 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #61 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
I/flutter (15597): #62 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
I/flutter (15597): #63 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
I/flutter (15597): #64 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
I/flutter (15597): #65 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #66 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
I/flutter (15597): #67 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #68 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
I/flutter (15597): #69 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
I/flutter (15597): #70 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5)
I/flutter (15597): #71 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #72 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
I/flutter (15597): #73 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #74 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
I/flutter (15597): #75 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
I/flutter (15597): #76 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
I/flutter (15597): #77 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
I/flutter (15597): #78 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #79 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
I/flutter (15597): #80 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
I/flutter (15597): #81 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
I/flutter (15597): #82 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
I/flutter (15597): #83 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #84 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
I/flutter (15597): #85 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
I/flutter (15597): #86 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5)
I/flutter (15597): #87 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #88 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
I/flutter (15597): #89 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
I/flutter (15597): #90 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5)
I/flutter (15597): #91 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #92 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
I/flutter (15597): #93 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
I/flutter (15597): #94 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
I/flutter (15597): #95 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
I/flutter (15597): #96 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
I/flutter (15597): #97 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
I/flutter (15597): #98 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
I/flutter (15597): #99 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
I/flutter (15597): #100 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2730:33)
I/flutter (15597): #101 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:913:20)
I/flutter (15597): #102 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:302:5)
I/flutter (15597): #103 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1117:15)
I/flutter (15597): #104 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1055:9)
I/flutter (15597): #105 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:971:5)
I/flutter (15597): #109 _invoke (dart:ui/hooks.dart:251:10)
I/flutter (15597): #110 _drawFrame (dart:ui/hooks.dart:209:3)
I/flutter (15597): (elided 3 frames from dart:async)
I/flutter (15597):
I/flutter (15597): ════════════════════════════════════════════════════════════════════════════════════════════════════
W/System (15597): A resource failed to call release.
W/System (15597): A resource failed to call release.
I saw on a Github thread, where I posted the issue, someone mentioning a similar event and others stating that this is to due with the current stable version of flutter causing this issue with the Camera Package: https://github.com/flutter/flutter/issues/60409?_pjax=%23js-repo-pjax-container
Any help or insight into this issue would be greatly appreciated!!!

Related

Null check operator used on a null value error on go_router deep link pop action

I am building a Flutter application -using Navigator 2.0 with go_router- with nested navigation on the bottom navigation bar, and 3 sub-route on the Home route: Single Post, Single Category, and Single Tag.
When I tried to open a single post URL on the browser, the deep link worked, and it opened the Single Post page on the app. But then, when I clicked the page's back button or the android back-gesture, it has thrown a _CastError: Null check operator used on a null value, and the Home page is not displayed.
What's wrong here, and how can I solve this?
Here is the source code: https://github.com/KweeksNews/kweeksnews_app/tree/develop (branch develop)
Error is thrown on this line: https://github.com/KweeksNews/kweeksnews_app/blob/11747545ab09dfc829ce02094ad16f9735cc39be/lib/core/widgets/navbar.dart#L68
Here is the debug log:
════════ Exception caught by widgets library ═══════════════════════════════════
The following _CastError was thrown, building Builder:
Null check operator used on a null value
The relevant error-causing widget was
MaterialApp
When the exception was thrown, this was the stack
#0 ScrollPosition.viewportDimension
#1 _PagePosition.getPixelsFromPage
#2 PageController.jumpToPage
#3 _NavBarState.didUpdateWidget
#4 StatefulElement.update
#5 Element.updateChild
#6 SingleChildRenderObjectElement.update
#7 Element.updateChild
#8 ComponentElement.performRebuild
#9 Element.rebuild
#10 StatelessElement.update
#11 Element.updateChild
#12 SingleChildRenderObjectElement.update
#13 Element.updateChild
#14 SingleChildRenderObjectElement.update
#15 Element.updateChild
#16 ComponentElement.performRebuild
#17 StatefulElement.performRebuild
#18 Element.rebuild
#19 StatefulElement.update
#20 Element.updateChild
#21 SingleChildRenderObjectElement.update
#22 Element.updateChild
#23 SingleChildRenderObjectElement.update
#24 Element.updateChild
#25 ComponentElement.performRebuild
#26 StatefulElement.performRebuild
#27 Element.rebuild
#28 StatefulElement.update
#29 Element.updateChild
#30 ComponentElement.performRebuild
#31 Element.rebuild
#32 StatelessElement.update
#33 Element.updateChild
#34 ComponentElement.performRebuild
#35 StatefulElement.performRebuild
#36 Element.rebuild
#37 StatefulElement.update
#38 Element.updateChild
#39 SingleChildRenderObjectElement.update
#40 Element.updateChild
#41 SingleChildRenderObjectElement.update
#42 Element.updateChild
#43 ComponentElement.performRebuild
#44 Element.rebuild
#45 ProxyElement.update
#46 _InheritedNotifierElement.update
#47 Element.updateChild
#48 SingleChildRenderObjectElement.update
#49 Element.updateChild
#50 ComponentElement.performRebuild
#51 StatefulElement.performRebuild
#52 Element.rebuild
#53 StatefulElement.update
#54 Element.updateChild
#55 ComponentElement.performRebuild
#56 Element.rebuild
#57 ProxyElement.update
#58 Element.updateChild
#59 ComponentElement.performRebuild
#60 Element.rebuild
#61 ProxyElement.update
#62 Element.updateChild
#63 ComponentElement.performRebuild
#64 StatefulElement.performRebuild
#65 Element.rebuild
#66 StatefulElement.update
#67 Element.updateChild
#68 ComponentElement.performRebuild
#69 Element.rebuild
#70 StatelessElement.update
#71 Element.updateChild
#72 ComponentElement.performRebuild
#73 Element.rebuild
#74 StatelessElement.update
#75 Element.updateChild
#76 SingleChildRenderObjectElement.update
#77 Element.updateChild
#78 ComponentElement.performRebuild
#79 Element.rebuild
#80 ProxyElement.update
#81 Element.updateChild
#82 ComponentElement.performRebuild
#83 Element.rebuild
#84 ProxyElement.update
#85 Element.updateChild
#86 ComponentElement.performRebuild
#87 StatefulElement.performRebuild
#88 Element.rebuild
#89 StatefulElement.update
#90 Element.updateChild
#91 ComponentElement.performRebuild
#92 StatefulElement.performRebuild
#93 Element.rebuild
#94 StatefulElement.update
#95 Element.updateChild
#96 ComponentElement.performRebuild
#97 StatefulElement.performRebuild
#98 Element.rebuild
#99 BuildOwner.buildScope
#100 WidgetsBinding.drawFrame
#101 RendererBinding._handlePersistentFrameCallback
#102 SchedulerBinding._invokeFrameCallback
#103 SchedulerBinding.handleDrawFrame
#104 SchedulerBinding._handleDrawFrame
#108 _invoke (dart:ui/hooks.dart:151:10)
#109 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308:5)
#110 _drawFrame (dart:ui/hooks.dart:115:31)
I'm not pretty sure about the real cause, but this is what I think happened.
So when the app opened using deep link into SingePost page, the app puts a page containing Navbar widget first into the page stack, and then puts the SinglePost page on top of it. Here it should be noted that the Navbar is not yet rendered by the app.
The Navbar widget's body is a PageView containing 4 page: Home, Search, SavedPosts, and Settings. All four pages are implementing AutomaticKeepAliveClientMixin to save and keep the scroll position, so that when user is navigating to the other pages and return, the scroll position is persist.
When user is popping out from the SinglePost page, the app then will render the Navbar with Home as the PageView's selected child (because the Navbar is given with index parameter of 0). Now the interesting and confusing part is, the didUpdateWidget is also called when the Navbar is being rendered by the app after user popping out from SinglePost page, even no parameter is changed (the index still 0). This will trigger a _pageController.jumpToPage() function, which, I think, in turn will try to render the requested page with the last saved scroll position. But because the page has never been rendered before, the scroll position is Null.
To fix this, now I put a check to make sure the new index is different with the current index before calling the _pageController.jumpToPage() function, and it worked.

[Flutter][BLoC] Error returning to previous widget

Lately i've been trying to update a profile.
So here's the scenario ,
HomePage => Drawer => Profile => HomePage .
When i return , this is the error i get.
⡿flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following assertion was thrown building BlocListener<HomeBloc, HomeState>(dirty, state:
flutter: _BlocListenerBaseState<HomeBloc, HomeState>#4a7df):
flutter: A build function returned null.
flutter: The offending widget is:
flutter: BlocListener<HomeBloc, HomeState>
flutter: Build functions must never return null.
flutter: To return an empty space that causes the building widget to fill available room, return
flutter: "Container()". To return an empty space that takes as little room as possible, return
flutter: "Container(width: 0.0, height: 0.0)".
flutter:
flutter: The relevant error-causing widget was:
flutter: BlocListener<HomeBloc, HomeState>
flutter: file:///Users/macbook/Documents/development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_bloc-6.0.6/lib/src/bloc_builder.dart:148:12
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 debugWidgetBuilderValue.<anonymous closure> (package:flutter/src/widgets/debug.dart:302:7)
flutter: #1 debugWidgetBuilderValue (package:flutter/src/widgets/debug.dart:323:4)
flutter: #2 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4632:7)
flutter: #3 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #4 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #5 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #6 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #7 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #8 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #9 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #10 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #11 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #12 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #13 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #14 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5)
flutter: #15 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #16 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #17 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #18 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #19 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #20 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #21 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #22 _InheritedProviderScopeElement.performRebuild (package:provider/src/inherited_provider.dart:426:11)
flutter: #23 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #24 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5)
flutter: #25 _InheritedProviderScopeElement.update (package:provider/src/inherited_provider.dart:446:11)
flutter: #26 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #27 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #28 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #29 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5)
flutter: #30 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #31 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #32 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #33 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5)
flutter: #34 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #35 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #36 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #37 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #38 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #39 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5)
flutter: #40 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #41 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #42 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #43 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #44 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #45 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #46 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #47 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #48 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #49 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #50 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5647:32)
flutter: #51 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6246:17)
flutter: #52 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #53 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #54 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #55 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #56 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #57 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #58 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #59 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #60 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #61 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #62 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #63 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #64 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #65 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #66 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #67 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #68 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #69 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #70 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #71 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #72 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #73 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #74 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #75 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #76 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #77 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #78 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #79 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #80 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #81 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5)
flutter: #82 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #83 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #84 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #85 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #86 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #87 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #88 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #89 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #90 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #91 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #92 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5)
flutter: #93 _InheritedNotifierElement.update (package:flutter/src/widgets/inherited_notifier.dart:183:11)
flutter: #94 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #95 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #96 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #97 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #98 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #99 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #100 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #101 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #102 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #103 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #104 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5)
flutter: #105 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #106 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #107 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #108 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #109 StatefulElement.update (package:flutter/src/widgets/framework.dart:4832:5)
flutter: #110 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #111 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #112 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #113 StatelessElement.update (package:flutter/src/widgets/framework.dart:4708:5)
flutter: #114 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #115 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6125:14)
flutter: #116 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #117 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #118 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #119 ProxyElement.update (package:flutter/src/widgets/framework.dart:4987:5)
flutter: #120 Element.updateChild (package:flutter/src/widgets/framework.dart:3314:15)
flutter: #121 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
flutter: #122 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
flutter: #123 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
flutter: #124 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2730:33)
flutter: #125 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:913:20)
flutter: #126 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:302:5)
flutter: #127 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1117:15)
flutter: #128 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1055:9)
flutter: #129 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:864:7)
flutter: (elided 4 frames from class _RawReceivePortImpl, class _Timer, and dart:async-patch)
flutter:
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
And this is my BlocConsumer code :
BlocConsumer<PrivateprofileBloc, PrivateprofileState>(
builder: (context, state) {
if (state is PrivateprofileInitial) {
return bodyBuild();
} else if (state is PrivateprofilePictureUpdate) {
this.user = state.user;
return bodyBuild();
} else if (state is PrivateprofileUpdate) {
this.user = state.user;
return bodyBuild();
} else if (state is PrivateprofileReturn) {
return BlocProvider(
create: (context) => HomeBloc(state.user),
child: HomePage(state.user));
}
},
listener: (context, state) {},
)
Any idea why ? the data get's updated , i get the Homepage back again with the updated data, but i get that error in the Terminal .
Because you didn't return Widget in 'else' case of BlocBuilder.
Just return empty Container in 'BlocBuilder'.
As I know that 'listener' returns 'void', you don't need to return anything.
BlocConsumer<HomeBloc, HomeState>(
builder: (context, state) {
if (state is HomeInitial) {
return buildBody();
} else if (state is HomeUpdatedUser) {
widget._user = state.user;
return buildBody();
}
return Container();
},
);

Invalid argument(s): No host specified in URI file:///p1

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,
);

Navigating to Another Page From TabBarView's child throws an error

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');
}

SchedulerBinding vs WidgetsBinding

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