My app is displaying lots of images, and some urls may not be valid.
This is the code i use to display the image:
(I use the cached_network_image plugin)
CachedNetworkImage(
imageUrl: images.first,
fit: BoxFit.cover,
placeholder: (context, url) => Center(
child: CircularProgressIndicator(),
),
errorWidget: (context, url, error) => Center(
child: const Icon(Icons.error)
)
)
Basically, there is the error that is thrown:
E/flutter (28425): [ERROR:flutter/lib/ui/painting/codec.cc(97)] Failed decoding image. Data is either invalid, or it is encoded using an unsupported format.
I/flutter (28425): ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
I/flutter (28425): The following _Exception was thrown resolving an image codec:
I/flutter (28425): Exception: operation failed
I/flutter (28425):
I/flutter (28425): When the exception was thrown, this was the stack:
I/flutter (28425): #0 FileImage._loadAsync (package:flutter/src/painting/image_provider.dart:564:12)
I/flutter (28425): <asynchronous suspension>
I/flutter (28425): #1 FileImage.load (package:flutter/src/painting/image_provider.dart:549:14)
I/flutter (28425): #2 ImageProvider.resolve.<anonymous closure>.<anonymous closure> (package:flutter/src/painting/image_provider.dart:285:105)
I/flutter (28425): #3 ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:157:22)
I/flutter (28425): #4 ImageProvider.resolve.<anonymous closure> (package:flutter/src/painting/image_provider.dart:285:82)
I/flutter (28425): #5 SynchronousFuture.then (package:flutter/src/foundation/synchronous_future.dart:38:29)
I/flutter (28425): #6 ImageProvider.resolve (package:flutter/src/painting/image_provider.dart:283:30)
I/flutter (28425): #7 _ImageState._resolveImage (package:flutter/src/widgets/image.dart:631:20)
I/flutter (28425): #8 _ImageState.didChangeDependencies (package:flutter/src/widgets/image.dart:606:5)
I/flutter (28425): #9 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3862:12)
I/flutter (28425): #10 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3711:5)
I/flutter (28425): #11 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2956:14)
I/flutter (28425): #12 Element.updateChild (package:flutter/src/widgets/framework.dart:2759:12)
I/flutter (28425): #13 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4883:14)
I/flutter (28425): #14 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter (28425): #15 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4601:32)
I/flutter (28425): #16 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4992:17)
I/flutter (28425): #17 Element.updateChild (package:flutter/src/widgets/framework.dart:2748:15)
I/flutter (28425): #18 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
I/flutter (28425): #19 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
I/flutter (28425): #20 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2273:33)
I/flutter (28425): #21 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:700:20)
I/flutter (28425): #22 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:268:5)
I/flutter (28425): #23 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:988:15)
I/flutter (28425): #24 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:928:9)
I/flutter (28425): #25 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:840:5)
I/flutter (28425): #29 _invoke (dart:ui/hooks.dart:209:10)
I/flutter (28425): #30 _drawFrame (dart:ui/hooks.dart:168:3)
I/flutter (28425): (elided 3 frames from package dart:async)
I/flutter (28425):
I/flutter (28425): Path:
I/flutter (28425): /data/user/0/xx.xxxx.xxxxxxxxxxx/cache/libCachedImageData/31c76660-5970-11e9-b769-3943ba44d1cb.html;
I/flutter (28425): charset=UTF-8
I/flutter (28425): ════════════════════════════════════════════════════════════════════════════════════════════════════
Notice that this url give some html... so that's normal
As I do not found any way to handle that error, i tried to use NetworkImageWithRetry from flutter_image package using:
FadeInImage(
placeholder: MemoryImage(kTransparentImage),
image: NetworkImageWithRetry(
imageUrl
),
fit: BoxFit.cover,
fadeInDuration: Duration(milliseconds: 150)
)
There is example of error that is thrown this time:
[ERROR:flutter/lib/ui/painting/codec.cc(97)] Failed decoding image. Data is either invalid, or it is encoded using an unsupported format.
I/flutter (31334): ══╡ EXCEPTION CAUGHT BY PACKAGE:FLUTTER_IMAGE ╞═════════════════════════════════════════════════════
I/flutter (31334): The following FetchFailure was thrown NetworkImageWithRetry failed to load
I/flutter (31334): xxxxxxxxxxxxxxxx :
I/flutter (31334): FetchFailure(
I/flutter (31334): attemptCount: 1
I/flutter (31334): httpStatusCode: null
I/flutter (31334): totalDuration: 0:00:05.969844
I/flutter (31334): originalException: Exception: operation failed
I/flutter (31334): )
I/flutter (31334): ════════════════════════════════════════════════════════════════════════════════════════════════════
This url send html...
The problem is that in release mode, I force close the app in case of any error, so i need to handle them
how can I just handle this types of error ?
Related
I have just started learning app development via Flutter. I ran into a tutorial to build a simple app.
My task is to add appbar and I did this:
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Hello '),
),
),
));
}
I am expecting a simple app bar with the title "Hello ".
I get this error in console :
-I/flutter (17741): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (17741): The following assertion was thrown building MyApp:
I/flutter (17741): MediaQuery.of() called with a context that does not contain a MediaQuery.
I/flutter (17741): No MediaQuery ancestor could be found starting from the context that was passed to MediaQuery.of().
I/flutter (17741): This can happen because you do not have a WidgetsApp or MaterialApp widget (those widgets introduce
I/flutter (17741): a MediaQuery), or it can happen if the context you use comes from a widget above those widgets.
I/flutter (17741): The context used was:
I/flutter (17741): Scaffold
I/flutter (17741):
I/flutter (17741): The relevant error-causing widget was:
I/flutter (17741): MyApp file:///E:/Flutter/i_am_rich/lib/main.dart:3:23
I/flutter (17741):
I/flutter (17741): When the exception was thrown, this was the stack:
I/flutter (17741): #0 MediaQuery.of (package:flutter/src/widgets/media_query.dart:798:5)
I/flutter (17741): #1 ScaffoldState.didChangeDependencies (package:flutter/src/material/scaffold.dart:1993:50)
I/flutter (17741): #2 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4376:12)
I/flutter (17741): #3 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
I/flutter (17741): #4 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
I/flutter (17741): #5 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
I/flutter (17741): #6 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
Reloaded 1 of 478 libraries in 437ms.
I/flutter (17741): #7 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
I/flutter (17741): #8 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2432:33)
I/flutter (17741): #9 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:773:20)
I/flutter (17741): #10 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:283:5)
I/flutter (17741): #11 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1102:15)
I/flutter (17741): #12 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1041:9)
I/flutter (17741): #13 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:850:7)
I/flutter (17741): #15 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:384:19)
I/flutter (17741): #16 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:418:5)
I/flutter (17741): #17 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
I/flutter (17741): (elided one frame from package dart:async-patch)
I/flutter (17741):
I/flutter (17741):
════════════════════════════════════════════════════════════════════════════════════════════════════
It would be great if you could provide me some insights into this.
Issue was solved on suggestion of #VirenVVarasadiya by running:
flutter clean
flutter run
I'm new to Flutter,
Right after creating my second app:
flutter create myapp && cd myapp && flutter run
I'm getting this exception. And although the app with the simple counter works in emulator, this exception doesn't look healthy, right?
Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode...
I/flutter ( 6000): ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 6000): The following assertion was thrown during a scheduler callback:
I/flutter ( 6000): There are multiple heroes that share the same tag within a subtree.
I/flutter ( 6000): Within each subtree for which heroes are to be animated (i.e. a PageRoute subtree), each Hero must
I/flutter ( 6000): have a unique non-null tag.
I/flutter ( 6000): In this case, multiple heroes had the following tag: <default FloatingActionButton tag>
...
(package:flutter/src/scheduler/binding.dart:1102:15)
I/flutter ( 6000): #141 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1049:9)
I/flutter ( 6000): #142 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:957:5)
I/flutter ( 6000): #146 _invoke (dart:ui/hooks.dart:259:10)
I/flutter ( 6000): #147 _drawFrame (dart:ui/hooks.dart:217:3)
I/flutter ( 6000): (elided 3 frames from package dart:async)
I/flutter ( 6000): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 6000): ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
I/flutter ( 6000): The following NetworkImageLoadException was thrown resolving an image codec:
I/flutter ( 6000): HTTP request failed, statusCode: 403,
I/flutter ( 6000): https://cdn.pixabay.com/photo/2016/04/10/21/34/woman-1320810_960_720.jpg
I/flutter ( 6000):
I/flutter ( 6000): When the exception was thrown, this was the stack:
I/flutter ( 6000): #0 NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:90:9)
I/flutter ( 6000): <asynchronous suspension>
I/flutter ( 6000): #1 NetworkImage.load (package:flutter/src/painting/_network_image_io.dart:47:14)
I/flutter ( 6000): #2 ImageProvider.resolve.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:flutter/src/painting/image_provider.dart:327:17)
I/flutter ( 6000): #3 ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:160:22)
...
(package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 6000): #213 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 6000): #214 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 6000): #215 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 6000): #216 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 6000): #217 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 6000): #218 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 6000): #219 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter ( 6000): #220 RenderObject.layout (package:flutter/src/rendering/object.dart:1724:7)
I/flutter ( 6000): #221 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:163:11)
I/flutter ( 6000): #222 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:477:7)
I/flutter ( 6000): #223 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:232:7)
I/flutter ( 6000): #224 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:391:14)
I/flutter ( 6000): #225 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1584:7)
I/flutter ( 6000): #226 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:844:18)
I/flutter ( 6000): #227 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:344:19)
I/flutter ( 6000): #228 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:774:13)
I/flutter ( 6000): #229 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:283:5)
I/flutter ( 6000): #230 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1102:15)
I/flutter ( 6000): #231 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1041:9)
I/flutter ( 6000): #232 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:957:5)
I/flutter ( 6000): #236 _invoke (dart:ui/hooks.dart:259:10)
I/flutter ( 6000): #237 _drawFrame (dart:ui/hooks.dart:217:3)
I/flutter ( 6000): (elided 6 frames from package dart:async)
I/flutter ( 6000):
I/flutter ( 6000): Image provider:
I/flutter ( 6000): NetworkImage("https://cdn.pixabay.com/photo/2016/04/10/21/34/woman-1320810_960_720.jpg", scale:
I/flutter ( 6000): 1.0)
I/flutter ( 6000): Image key: NetworkImage("https://cdn.pixabay.com/photo/2016/04/10/21/34/woman-1320810_960_720.jpg",
I/flutter ( 6000): scale: 1.0)
I/flutter ( 6000): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter ( 6000): Another exception was thrown: There are multiple heroes that share the same tag within a subtree.
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 26.5s
✓ Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk... 8.8s
Syncing files to device Android SDK built for x86...
10,951ms (!)
Do you have any idea why? Thanks!
The starter Flutter app doesn't contain things like loading network images as it's just a simple counter app. As Vijaya said, it's probably just an old error from another project. I get the same stuff when I use flutter run. Unless you edited the flutter create template, you have nothing to worry about.
I get this error sometimes in my app, but I'm unsure of its origin because this is all it provides me with
I/flutter (10601): #0 _AsyncCompleter.complete (dart:async/future_impl.dart:39:31)
I/flutter (10601): #1 Route.didComplete (package:flutter/src/widgets/navigator.dart:189:19)
I/flutter (10601): #2 NavigatorState.pushReplacement.<anonymous closure> (package:flutter/src/widgets/navigator.dart:1846:13)
I/flutter (10601): #3 TickerFuture.whenCompleteOrCancel.thunk (package:flutter/src/scheduler/ticker.dart:389:15)
I/flutter (10601): #4 _rootRunUnary (dart:async/zone.dart:1132:38)
I/flutter (10601): #5 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
I/flutter (10601): #6 _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
I/flutter (10601): #7 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
I/flutter (10601): #8 Future._propagateToListeners (dart:async/future_impl.dart:668:32)
I/flutter (10601): #9 Future._completeWithValue (dart:async/future_impl.dart:483:5)
I/flutter (10601): #10 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:513:7)
I/flutter (10601): #11 _rootRun (dart:async/zone.dart:1124:13)
I/flutter (10601): #12 _CustomZone.run (dart:async/zone.dart:1021:19)
I/flutter (10601): #13 _CustomZone.runGuarded (dart:async/zone.dart
I/flutter (10601): Caught error: Bad state: Future already completed
I'm unsure why this was happening mostly because the logging is inadequate, but I think it may have something to do with the pushReplacementNamed function.
Actually I am working on Login page with Bloc. So when I press submit button, it does business logic on bloc then trying to navigate to home page based on the result. I tried this
Widget submitButton() {
return StreamBuilder(
stream: bloc.submitStream,
builder: (context, snapshot) {
if (snapshot.data == "Success") {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => RegisterPage(),
),
);
}
return RaisedButton(
child: Text("Submit"),
onPressed: () {
bloc.submitSink.add(null);
},
);
},
);
}
But I got error like this The widget which was currently being built when the offending call was made....
Later then I found two solution:
1. Using SchedulerBinding,
2. Using WidgetsBinding. So what is the difference between SchedulerBinding and WidgetsBinding. Which one do I have to use?
Full Error Log:
I/flutter (17893): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (17893): The following assertion was thrown building LayoutBuilder:
I/flutter (17893): setState() or markNeedsBuild() called during build.
I/flutter (17893): This Overlay widget cannot be marked as needing to build because the framework is already in the
I/flutter (17893): process of building widgets. A widget can be marked as needing to be built during the build phase
I/flutter (17893): only if one of its ancestors is currently building. This exception is allowed because the framework
I/flutter (17893): builds parent widgets before children, which means a dirty descendant will always be built.
I/flutter (17893): Otherwise, the framework might not visit this widget during this build phase.
I/flutter (17893): The widget on which setState() or markNeedsBuild() was called was:
I/flutter (17893): Overlay-[LabeledGlobalKey<OverlayState>#70089](state: OverlayState#3bf13(entries:
I/flutter (17893): [OverlayEntry#9280a(opaque: false; maintainState: false), OverlayEntry#1af87(opaque: false;
I/flutter (17893): maintainState: true), OverlayEntry#9fb49(opaque: false; maintainState: false),
I/flutter (17893): OverlayEntry#87589(opaque: false; maintainState: true)]))
I/flutter (17893): The widget which was currently being built when the offending call was made was:
I/flutter (17893): LayoutBuilder(renderObject: _RenderLayoutBuilder#d3baf relayoutBoundary=up1 NEEDS-LAYOUT
I/flutter (17893): NEEDS-PAINT)
I/flutter (17893):
I/flutter (17893): When the exception was thrown, this was the stack:
I/flutter (17893): #0 Element.markNeedsBuild.<anonymous closure> (package:flutter/src/widgets/framework.dart:3497:11)
I/flutter (17893): #1 Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:3523:6)
I/flutter (17893): #2 State.setState (package:flutter/src/widgets/framework.dart:1138:14)
I/flutter (17893): #3 OverlayState.insertAll (package:flutter/src/widgets/overlay.dart:301:5)
I/flutter (17893): #4 OverlayRoute.install (package:flutter/src/widgets/routes.dart:43:24)
I/flutter (17893): #5 TransitionRoute.install (package:flutter/src/widgets/routes.dart:184:11)
I/flutter (17893): #6 ModalRoute.install (package:flutter/src/widgets/routes.dart:899:11)
I/flutter (17893): #7 NavigatorState.push (package:flutter/src/widgets/navigator.dart:1672:11)
I/flutter (17893): #8 Navigator.push (package:flutter/src/widgets/navigator.dart:1011:34)
I/flutter (17893): #9 _SetPinPageState.submitButton (package:technicalreport/screens/set_pin_page.dart:94:15)
I/flutter (17893): #10 _SetPinPageState.build.<anonymous closure>.<anonymous closure> (package:technicalreport/screens/set_pin_page.dart:52:29)
I/flutter (17893): #11 OrientationBuilder._buildWithConstraints (package:flutter/src/widgets/orientation_builder.dart:48:12)
I/flutter (17893): #12 _LayoutBuilderElement._layout.<anonymous closure> (package:flutter/src/widgets/layout_builder.dart:111:26)
I/flutter (17893): #13 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2253:19)
I/flutter (17893): #14 _LayoutBuilderElement._layout (package:flutter/src/widgets/layout_builder.dart:107:11)
I/flutter (17893): #15 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1728:58)
I/flutter (17893): #16 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:797:15)
I/flutter (17893): #17 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1728:13)
I/flutter (17893): #18 _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:205:5)
I/flutter (17893): #19 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #20 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11)
I/flutter (17893): #21 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:350:7)
I/flutter (17893): #22 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7)
I/flutter (17893): #23 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14)
I/flutter (17893): #24 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #25 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #26 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #27 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #28 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1206:11)
I/flutter (17893): #29 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #30 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #31 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #32 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #33 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #34 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #35 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #36 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #37 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #38 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #39 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #40 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #41 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #42 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #43 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #44 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #45 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3032:13)
I/flutter (17893): #46 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #47 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
I/flutter (17893): #48 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #49 __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #50 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #51 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #52 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #53 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #54 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #55 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #56 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #57 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
I/flutter (17893): #58 RenderObject.layout (package:flutter/src/rendering/object.dart:1632:7)
I/flutter (17893): #59 RenderView.performLayout (package:flutter/src/rendering/view.dart:151:13)
I/flutter (17893): #60 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1507:7)
I/flutter (17893): #61 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:766:18)
I/flutter (17893): #62 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:329:19)
I/flutter (17893): #63 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:701:13)
I/flutter (17893): #64 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:268:5)
I/flutter (17893): #65 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:988:15)
I/flutter (17893): #66 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:928:9)
I/flutter (17893): #67 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:749:7)
I/flutter (17893): #76 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
I/flutter (17893): #77 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
I/flutter (17893): #78 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter (17893): (elided 8 frames from package dart:async)
I/flutter (17893): ════════════════════════════════════════════════════════════════════════════════════════════════════
D/ (17893): HostConnection::get() New Host Connection established 0xa0ba6b40, tid 17931
D/EGL_emulation(17893): eglMakeCurrent: 0xa3508c40: ver 2 0 (tinfo 0x9084ab40)
There are three callbacks available in flutter which rendering flutter widgets.
Transient callbacks: triggered by the system’s [Window.onBeginFrame] callback, for synchronizing the application’s behavior to the system’s display. For example, [Ticker]s and [AnimationController]s trigger from these.
Persistent callbacks: triggered by the system’s [Window.onDrawFrame] callback, for updating the system’s display after transient callbacks have executed. For example, the rendering layer uses this to drive its rendering pipeline.
Post-frame callbacks: which are run after persistent callbacks, just before returning from the [Window.onDrawFrame] callback. * Non-rendering tasks, to be run between frames. These are given a priority and are executed in priority order according to a schedulingStrategy.
All above callbacks run sequentially, but for us, the last callback would work i.e Post-frame callbacks
Widgets Binding: The glue between the widgets layer and the Flutter engine. which comes with WidgetsBindingObserver mixin which has many callbacks but one which required to use is didChangeAppLifecycleState that returns AppLifecycleState.
Scheduler Binding: This is also similar to WidgetBinding but it does not provide any life cycle callbacks.
The below binding example would be called exactly the ones, means print statement like WidgetsBinding & SchedulerBinding will be printed only once as we called it initState(), but it will be called when build method finished it’s rendering.
void initState() {
super.initState();
print("initState");
WidgetsBinding.instance.addPostFrameCallback((_) {
print("WidgetsBinding");
});
SchedulerBinding.instance.addPostFrameCallback((_) {
print("SchedulerBinding");
});
}
Both solutions do the same.
WidgetsBinding inherits this Method from SchedulerBinding
https://api.flutter.dev/flutter/widgets/WidgetsBinding-mixin.html
It registers a callback that will be called after the frame is build.
See in the docs:
https://api.flutter.dev/flutter/scheduler/SchedulerBinding/addPostFrameCallback.html
I want to have a dialog that takes my user through an authentication flow. It will need the following widgets:
Choose auth method (Google, Facebook, email, phone, etc)
Enter email address
Enter phone number
Enter code from (email/phone)
What I'm trying to do is create an AlertDialog with a PageView widget that will be navigated via the PageController (I have set physics: NeverScrollableScrollPhysics() to prevent the user from scrolling around). The whole idea here is I'd like the dialog to always remain the same size (which I understand PageView will measure all the children and should allow me to do this.
I tried creating the PageView with 3 Text widgets and I get the following error:
I/flutter (16052): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (16052): The following assertion was thrown during performLayout():
I/flutter (16052): RenderViewport does not support returning intrinsic dimensions.
I/flutter (16052): Calculating the intrinsic dimensions would require instantiating every child of the viewport, which
I/flutter (16052): defeats the point of viewports being lazy.
I/flutter (16052): If you are merely trying to shrink-wrap the viewport in the main axis direction, consider a
I/flutter (16052): RenderShrinkWrappingViewport render object (ShrinkWrappingViewport widget), which achieves that
I/flutter (16052): effect without implementing the intrinsic dimension API.
I/flutter (16052):
I/flutter (16052): When the exception was thrown, this was the stack:
I/flutter (16052): #0 RenderViewportBase.debugThrowIfNotCheckingIntrinsics.<anonymous closure> (package:flutter/src/rendering/viewport.dart:299:9)
I/flutter (16052): #1 RenderViewportBase.debugThrowIfNotCheckingIntrinsics (package:flutter/src/rendering/viewport.dart:309:6)
I/flutter (16052): #2 RenderViewportBase.computeMaxIntrinsicWidth (package:flutter/src/rendering/viewport.dart:321:12)
I/flutter (16052): #3 RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1099:23)
I/flutter (16052): #4 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.putIfAbsent (dart:collection/runtime/libcompact_hash.dart:284:23)
I/flutter (16052): #5 RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1097:41)
I/flutter (16052): #6 RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1281:12)
I/flutter (16052): #7 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:76:20)
I/flutter (16052): #8 RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1099:23)
I/flutter (16052): #9 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.putIfAbsent (dart:collection/runtime/libcompact_hash.dart:284:23)
I/flutter (16052): #10 RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1097:41)
I/flutter (16052): #11 RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1281:12)
I/flutter (16052): #12 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:76:20)
I/flutter (16052): #13 RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1099:23)
I/flutter (16052): #14 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.putIfAbsent (dart:collection/runtime/libcompact_hash.dart:284:23)
I/flutter (16052): #15 RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1097:41)
I/flutter (16052): #16 RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1281:12)
I/flutter (16052): #17 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:76:20)
I/flutter (16052): #18 RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1099:23)
I/flutter (16052): #19 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.putIfAbsent (dart:collection/runtime/libcompact_hash.dart:284:23)
I/flutter (16052): #20 RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1097:41)
I/flutter (16052): #21 RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1281:12)
I/flutter (16052): #22 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:76:20)
I/flutter (16052): #23 RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1099:23)
I/flutter (16052): #24 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.putIfAbsent (dart:collection/runtime/libcompact_hash.dart:284:23)
I/flutter (16052): #25 RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1097:41)
I/flutter (16052): #26 RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1281:12)
I/flutter (16052): #27 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:76:20)
I/flutter (16052): #28 RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1099:23)
I/flutter (16052): #29 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.putIfAbsent (dart:collection/runtime/libcompact_hash.dart:284:23)
I/flutter (16052): #30 RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1097:41)
I/flutter (16052): #31 RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1281:12)
I/flutter (16052): #32 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:76:20)
I/flutter (16052): #33 RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1099:23)
I/flutter (16052): #34 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.putIfAbsent (dart:collection/runtime/libcompact_hash.dart:284:23)
I/flutter (16052): #35 RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1097:41)
I/flutter (16052): #36 RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1281:12)
I/flutter (16052): #37 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:76:20)
I/flutter (16052): #38 RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1099:23)
I/flutter (16052): #39 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.putIfAbsent (dart:collection/runtime/libcompact_hash.dart:284:23)
I/flutter (16052): #40 RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1097:41)
I/flutter (16052): #41 RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1281:12)
I/flutter (16052): #42 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.computeMaxIntrinsicWidth (package:flutter/src/rendering/proxy_box.dart:76:20)
I/flutter (16052): #43 RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1099:23)
I/flutter (16052): #44 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.putIfAbsent (dart:collection/runtime/libcompact_hash.dart:284:23)
I/flutter (16052): #45 RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1097:41)
I/flutter (16052): #46 RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1281:12)
I/flutter (16052): #47 RenderPadding.computeMaxIntrinsicWidth (package:flutter/src/rendering/shifted_box.dart:163:20)
I/flutter (16052): #48 RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1099:23)
I/flutter (16052): #49 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.putIfAbsent (dart:collection/runtime/libcompact_hash.dart:284:23)
I/flutter (16052): #50 RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1097:41)
I/flutter (16052): #51 RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1281:12)
I/flutter (16052): #52 RenderFlex.computeMaxIntrinsicWidth.<anonymous closure> (package:flutter/src/rendering/flex.dart:575:60)
I/flutter (16052): #53 RenderFlex._getIntrinsicSize (package:flutter/src/rendering/flex.dart:552:58)
I/flutter (16052): #54 RenderFlex.computeMaxIntrinsicWidth (package:flutter/src/rendering/flex.dart:572:12)
I/flutter (16052): #55 RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1099:23)
I/flutter (16052): #56 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.putIfAbsent (dart:collection/runtime/libcompact_hash.dart:284:23)
I/flutter (16052): #57 RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1097:41)
I/flutter (16052): #58 RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1281:12)
I/flutter (16052): #59 RenderIntrinsicWidth.performLayout (package:flutter/src/rendering/proxy_box.dart:617:36)
I/flutter (16052): #60 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #61 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (16052): #62 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #63 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (16052): #64 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #65 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (16052): #66 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #67 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (16052): #68 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1188:11)
I/flutter (16052): #69 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #70 RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:258:13)
I/flutter (16052): #71 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #72 RenderPositionedBox.performLayout (package:flutter/src/rendering/shifted_box.dart:385:13)
I/flutter (16052): #73 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #74 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:199:11)
I/flutter (16052): #75 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #76 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:199:11)
I/flutter (16052): #77 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #78 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (16052): #79 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #80 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (16052): #81 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #82 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (16052): #83 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #84 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (16052): #85 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #86 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (16052): #87 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #88 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (16052): #89 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #90 _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter (16052): #91 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:2881:13)
I/flutter (16052): #92 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter (16052): #93 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
I/flutter (16052): #94 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
I/flutter (16052): #95 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
I/flutter (16052): #96 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
I/flutter (16052): #97 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:677:13)
I/flutter (16052): #98 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter (16052): #99 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (16052): #100 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (16052): #101 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter (16052): #102 _invoke (dart:ui/hooks.dart:154:13)
I/flutter (16052): #103 _drawFrame (dart:ui/hooks.dart:143:3)
I/flutter (16052):
I/flutter (16052): The following RenderObject was being processed when the exception was fired:
I/flutter (16052): RenderIntrinsicWidth#88cfa relayoutBoundary=up6 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (16052): creator: IntrinsicWidth ← Semantics ← DefaultTextStyle ← AnimatedDefaultTextStyle ←
I/flutter (16052): _InkFeatures-[GlobalKey#8e5bb ink renderer] ← NotificationListener<LayoutChangedNotification> ←
I/flutter (16052): CustomPaint ← _ShapeBorderPaint ← PhysicalShape ← _MaterialInterior ← Material ← ConstrainedBox ←
I/flutter (16052): ⋯
I/flutter (16052): parentData: <none> (can use size)
I/flutter (16052): constraints: BoxConstraints(280.0<=w<=331.4, 0.0<=h<=611.4)
I/flutter (16052): size: MISSING
I/flutter (16052): stepWidth: null
I/flutter (16052): stepHeight: null
I/flutter (16052): This RenderObject had the following descendants (showing up to depth 5):
I/flutter (16052): RenderFlex#1cdae NEEDS-LAYOUT NEEDS-PAINT
I/flutter (16052): RenderPadding#3c952 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (16052): RenderRepaintBoundary#2e299 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (16052): RenderCustomPaint#4dd7f NEEDS-LAYOUT NEEDS-PAINT
I/flutter (16052): RenderRepaintBoundary#ebf6b NEEDS-LAYOUT NEEDS-PAINT
I/flutter (16052): RenderPadding#31e20 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (16052): RenderFlex#8072a NEEDS-LAYOUT NEEDS-PAINT
I/flutter (16052): RenderPadding#a5f11 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (16052): RenderSemanticsAnnotations#f63f2 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (16052): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (16052): Another exception was thrown: RenderBox was not laid out: RenderIntrinsicWidth#88cfa relayoutBoundary=up6 NEEDS-PAINT
I/flutter (16052): Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#ca67f relayoutBoundary=up5 NEEDS-PAINT
I/flutter (16052): Another exception was thrown: RenderBox was not laid out: _RenderInkFeatures#a2ca4 relayoutBoundary=up4 NEEDS-PAINT
I/flutter (16052): Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#b4d9b relayoutBoundary=up3 NEEDS-PAINT
I/flutter (16052): Another exception was thrown: RenderBox was not laid out: RenderPhysicalShape#235a2 relayoutBoundary=up2 NEEDS-PAINT
I/flutter (16052): Another exception was thrown: 'package:flutter/src/rendering/shifted_box.dart': Failed assertion: line 314 pos 12: 'child.hasSize': is not true.
I/flutter (16052): Another exception was thrown: RenderBox was not laid out: RenderPhysicalShape#235a2 relayoutBoundary=up2
If there's a better way to do this, I'm open to it as long as the dialog won't resize.
UPDATE:
Here's a minimal sample, simply launch the following dialog:
AlertDialog(
content: PageView(
children: <Widget> [
Text('child1'),
Text('child2'),
Text('child3'),
],
),
);
The problem appears that PageView doesn't instantiate all the views right away but does it lazily to save CPU cycles. This means that AlertDialog can't size itself. I'm trying to figure out if there's a way to override PageView's default behavior and have it measure its size right away maybe?
UPDATE:
While I haven't been able to do anything with PageView I've been able to mimic the behavior I want with a simple IndexedStack. It just lacks the animations when programmatically moving between pages, but hopefully I'll be able to add that in. I'll post a final answer once finished.
Just wrap your PageView with a Container and specify its width and height will do the work.
AlertDialog(
Container(
width: width,
height: height,
child: PageView(
...
),
),
)