-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
I ran into a run time issue on iOS simulator that does not appear to affect a real device. I'm running the code via flutter run --no-preview-dart-2.
The same code does not crash a real device, and works fine on real and emulator Android devices.
I have isolated the code that causes it and have added that below.
Steps to Reproduce
The following code crashes the app in iOS Simulator when showing a dialog:
void main() {
runApp( new MaterialApp(
home: new Scaffold(
appBar: new AppBar( title: const Text("TEST") ),
body: new TestUI(),
)
) );
}
class TestUI extends StatefulWidget {
@override
State<StatefulWidget> createState() => new _TestUIState();
}
class _TestUIState extends State<TestUI> {
@override
Widget build(BuildContext context) {
return new Container(
alignment: FractionalOffset.center,
child: new GestureDetector(
child: const Icon(Icons.title),
onTapDown: (TapDownDetails d) async {
await bugTestDialog( context, title:"foo", body:"bar" );
},
)
);
}
}
Future bugTestDialog( BuildContext context,
{String title,
String body}
) async {
return showDialog(context: context, builder: (BuildContext context) {
final double screenHeight = MediaQuery.of(context).size.height;
final double dialogHeight = screenHeight * 0.75;
final double whiteSpace = 12.0;
final double buttonRowHeight = 48.0;
final double listViewHeight = dialogHeight - buttonRowHeight;
TextTheme textTheme;
try {
textTheme = Theme
.of(context)
.textTheme;
}
catch(e) {
return null;
}
final Widget bannerIcon = null;
final Widget bannerTop = null;
final List<Widget> bodyChildren = <Widget>[];
if (title != null) {
bodyChildren.add(
new Container(
margin: const EdgeInsets.all(16.0),
child: new Text( title )
)
);
}
if (body != null) bodyChildren.add(
new Container(
padding: const EdgeInsets.fromLTRB(16.0, 10.0, 16.0, 0.0),
child: new Text( body )
)
);
final List<Widget> actions = <Widget>[];
actions.add(
new Container(
margin: new EdgeInsets.only( top: whiteSpace ),
alignment: FractionalOffset.center,
child: new FlatButton( child: const Icon(Icons.stop),
onPressed: () {
Navigator.of(context).pop( true );
},
)
)
);
actions.add( new SizedBox( height: whiteSpace ) );
bodyChildren.add( new SizedBox( height: 12.0 ));
final List<Widget> dialogChildren = <Widget>[
new Container( constraints: new BoxConstraints(maxHeight:listViewHeight), child: new Scrollbar( child: new ListView( children: bodyChildren, shrinkWrap: true ) ) ),
new Column( mainAxisSize: MainAxisSize.min, children: actions ),
];
final AlertDialog dialog = new AlertDialog(
title: bannerTop,
titlePadding: EdgeInsets.zero,
contentPadding: const EdgeInsets.all(0.0),
content: new Column( mainAxisSize: MainAxisSize.min, children: dialogChildren ),
//actions: actions,
);
return dialog;
} );
}Logs
══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
RenderShrinkWrappingViewport does not support returning intrinsic dimensions.
Calculating the intrinsic dimensions would require instantiating every child of the viewport, which
defeats the point of viewports being lazy.
If you are merely trying to shrink-wrap the viewport in the main axis direction, you should be able
to achieve that effect by just giving the viewport loose constraints, without needing to measure its
intrinsic dimensions.
When the exception was thrown, this was the stack:
#0 RenderShrinkWrappingViewport.debugThrowIfNotCheckingIntrinsics.<anonymous closure> (package:flutter/src/rendering/viewport.dart:1239:9)
#1 RenderShrinkWrappingViewport.debugThrowIfNotCheckingIntrinsics (package:flutter/src/rendering/viewport.dart:1249:6)
#2 RenderViewportBase.computeMaxIntrinsicHeight (package:flutter/src/rendering/viewport.dart:227:12)
#3 RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1063:23)
#4 _HashVMBase&MapMixin&&_LinkedHashMapMixin.putIfAbsent (dart:collection-patch/dart:collection/compact_hash.dart:277)
#5 RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1061:41)
#6 RenderBox.getMaxIntrinsicHeight (package:flutter/src/rendering/box.dart:1394:12)
#7 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.computeMaxIntrinsicHeight (package:flutter/src/rendering/proxy_box.dart:93:20)
#8 RenderBox._computeIntrinsicDimension.<anonymous closure> (package:flutter/src/rendering/box.dart:1063:23)
#9 _HashVMBase&MapMixin&&_LinkedHashMapMixin.putIfAbsent (dart:collection-patch/dart:collection/compact_hash.dart:277)
#10 RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1061:41)
#11 RenderBox.getMaxIntrinsicHeight (package:flutter/src/rendering/box.dart:1394:12)
(snipped)
#107 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
#108 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
#109 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
#110 _invoke (file:///b/build/slave/Mac_Engine/build/src/flutter/lib/ui/hooks.dart:120)
#111 _drawFrame (file:///b/build/slave/Mac_Engine/build/src/flutter/lib/ui/hooks.dart:109)
The following RenderObject was being processed when the exception was fired:
RenderIntrinsicWidth#e53ba relayoutBoundary=up5 NEEDS-LAYOUT NEEDS-PAINT
creator: IntrinsicWidth ← DefaultTextStyle ← AnimatedDefaultTextStyle ←
_InkFeatures-[GlobalKey#8b1fe ink renderer] ← NotificationListener<LayoutChangedNotification> ←
CustomPaint ← _ShapeBorderPaint ← PhysicalShape ← _MaterialInterior ← Material ← ConstrainedBox ←
Center ← ⋯
parentData: <none> (can use size)
constraints: BoxConstraints(280.0<=w<=295.0, 0.0<=h<=599.0)
size: MISSING
stepWidth: null
stepHeight: null
This RenderObject had the following descendants (showing up to depth 5):
RenderFlex#5deb1 NEEDS-LAYOUT NEEDS-PAINT
RenderPadding#c223a NEEDS-LAYOUT NEEDS-PAINT
RenderFlex#cf2db NEEDS-LAYOUT NEEDS-PAINT
RenderConstrainedBox#36077 NEEDS-LAYOUT NEEDS-PAINT
RenderRepaintBoundary#2fac1 NEEDS-LAYOUT NEEDS-PAINT
RenderFlex#6d083 NEEDS-LAYOUT NEEDS-PAINT
RenderPadding#53b3e NEEDS-LAYOUT NEEDS-PAINT
RenderConstrainedBox#3bda6 NEEDS-LAYOUT NEEDS-PAINT
Flutter Doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.2.8, on Mac OS X 10.13.4 17E199, locale en-NL)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.io/setup/#android-setup for detailed instructions).
If Android SDK has been installed to a custom location, set $ANDROID_HOME to that location.
[✓] iOS toolchain - develop for iOS devices (Xcode 9.3)
[✓] Android Studio (version 3.0)
[✓] Connected devices (1 available)