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,
);
Related
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!!!
This is my problem and I don't know how can fix it. Please help me
Github of this project: here
Launching lib/main.dart on iPhone SE (2nd generation) in debug mode...
Running Xcode build...
Xcode build done. 22.0s
Configuring the default Firebase app...
Configured the default Firebase app __FIRAPP_DEFAULT.
Waiting for iPhone SE (2nd generation) to report its views...
Debug service listening on ws://127.0.0.1:54630/tFUTjcfl640=/ws
Syncing files to device iPhone SE (2nd generation)...
flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following assertion was thrown building StreamBuilder<CalendarDetailModel>(dirty, state:
flutter: _StreamBuilderBaseState<CalendarDetailModel, AsyncSnapshot<CalendarDetailModel>>#836df):
flutter: A build function returned null.
flutter: The offending widget is:
flutter: StreamBuilder<CalendarDetailModel>
flutter: Build functions must never return null.
flutter: To return an empty space that causes the building widget to fill available room, return
flutter: "Container()". To return an empty space that takes as little room as possible, return
flutter: "Container(width: 0.0, height: 0.0)".
flutter:
flutter: The relevant error-causing widget was:
flutter: StreamBuilder<CalendarDetailModel>
flutter: file:///Users/lethanhtu/Desktop/firebase_authentication/lib/ui/calendar_detail.dart:54:20
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 debugWidgetBuilderValue.<anonymous closure> (package:flutter/src/widgets/debug.dart:276:7)
flutter: #1 debugWidgetBuilderValue (package:flutter/src/widgets/debug.dart:297:4)
flutter: #2 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4516:7)
flutter: #3 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4684:11)
flutter: #4 Element.rebuild (package:flutter/src/widgets/framework.dart:4227:5)
flutter: #5 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4490:5)
flutter: #6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4675:11)
flutter: #7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4485:5)
flutter: ... Normal element mounting (39 frames)
flutter: #46 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3455:14)
flutter: #47 Element.updateChild (package:flutter/src/widgets/framework.dart:3223:18)
flutter: #48 SliverMultiBoxAdaptorElement.updateChild (package:flutter/src/widgets/sliver.dart:1162:36)
flutter: #49 SliverMultiBoxAdaptorElement.createChild.<anonymous closure> (package:flutter/src/widgets/sliver.dart:1147:20)
flutter: #50 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2612:19)
flutter: #51 SliverMultiBoxAdaptorElement.createChild (package:flutter/src/widgets/sliver.dart:1140:11)
flutter: #52 RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure> (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:354:23)
flutter: #53 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1866:58)
flutter: #54 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:918:15)
flutter: #55 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1866:13)
flutter: #56 RenderSliverMultiBoxAdaptor._createOrObtainChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:343:5)
flutter: #57 RenderSliverMultiBoxAdaptor.addInitialChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:427:5)
flutter: #58 RenderSliverList.performLayout (package:flutter/src/rendering/sliver_list.dart:79:12)
flutter: #59 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #60 RenderSliverEdgeInsetsPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:135:11)
flutter: #61 RenderSliverPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:375:11)
flutter: #62 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #63 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:452:13)
flutter: #64 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1443:12)
flutter: #65 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1352:20)
flutter: #66 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #67 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #68 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #69 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #70 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #71 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #72 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #73 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #74 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #75 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #76 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #77 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #78 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #79 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #80 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #81 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #82 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #83 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:207:11)
flutter: #84 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #85 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:171:11)
flutter: #86 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:480:7)
flutter: #87 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:240:7)
flutter: #88 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:399:14)
flutter: #89 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #90 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #91 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #92 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #93 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1267:11)
flutter: #94 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #95 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #96 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #97 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #98 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #99 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #100 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #101 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:556:15)
flutter: #102 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #103 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #104 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #105 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #106 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #107 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #108 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #109 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #110 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #111 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #112 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #113 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #114 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3219:13)
flutter: #115 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #116 _RenderTheatre.performLayout (package:flutter/src/widgets/overlay.dart:700:15)
flutter: #117 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #118 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #119 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #120 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #121 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #122 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #123 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #124 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #125 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #126 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:113:13)
flutter: #127 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
flutter: #128 RenderView.performLayout (package:flutter/src/rendering/view.dart:167:13)
flutter: #129 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1630:7)
flutter: #130 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:887:18)
flutter: #131 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:402:19)
flutter: #132 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:865:13)
flutter: #133 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:284:5)
flutter: #134 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1113:15)
flutter: #135 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1052:9)
flutter: #136 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:861:7)
flutter: (elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
flutter:
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Status code is 200
[VERBOSE-2:ui_dart_state.cc(166)] Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'Map<String, String>'
#0 new CalendarDetailModel (package:firebaseauthentication/models/calendar_detail_model.dart:26:40)
#1 CalendarDetailRepository.fetchRoom.<anonymous closure> (package:firebaseauthentication/resources/calendar_detail_repository.dart:38:23)
#2 List.forEach (dart:core-patch/growable_array.dart:289:8)
#3 CalendarDetailRepository.fetchRoom (package:firebaseauthentication/resources/calendar_detail_repository.dart:35:19)
<asynchronous suspension>
#4 CalendarDetailBloc.loadRoom (package:firebaseauthentication/blocs/calendar_detail_bloc.dart:16:36)
#5 CalendarDetailsState.initState (package:firebaseauthentication/ui/calendar_detail.dart:35:10)
#6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4649:58)
#7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4485:5)
#8 Element.inflateWidget (package:flutter/<…>
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building StreamBuilder<CalendarDetailModel>(dirty, state: _StreamBuilderBaseState<CalendarDetailModel, AsyncSnapshot<CalendarDetailModel>>#836df):
A build function returned null.
The offending widget is: StreamBuilder<CalendarDetailModel>
Build functions must never return null.
To return an empty space that causes the building widget to fill available room, return "Container()". To return an empty space that takes as little room as possible, return "Container(width: 0.0, height: 0.0)".
The relevant error-causing widget was:
StreamBuilder<CalendarDetailModel> file:///Users/lethanhtu/Desktop/firebase_authentication/lib/ui/calendar_detail.dart:54:20
When the exception was thrown, this was the stack:
#0 debugWidgetBuilderValue.<anonymous closure> (package:flutter/src/widgets/debug.dart:276:7)
#1 debugWidgetBuilderValue (package:flutter/src/widgets/debug.dart:297:4)
#2 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4516:7)
#3 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4684:11)
#4 Element.rebuild (package:flutter/src/widgets/framework.dart:4227:5)
...
════════════════════════════════════════════════════════════════════════════════════════════════════
The error is quite clear about what the issue is. In you StreamBuilder you are not awlays returning something. You have:
builder: (context, snapshot) {
if (snapshot.hasError) {
return CircularProgressIndicator();
} else if (snapshot.hasData) {
...
}
which only returns something on an error or when data is available. However, there won't always be data available or an error, so you have to return something when neither of these conditions are true.
Simply adding return CircularProgressIndicator(); outside of these if-else blocks or in an else statement will solve your issue.
Ex.
builder: (context, snapshot) {
if (snapshot.hasError) {
return CircularProgressIndicator();
} else if (snapshot.hasData) {
...
}
else {
return CircularProgressIndicator();
}
Following the instructions that these errors provide can save you a lot of time and takes away the need to ask here on SO.
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
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