Unverified Commit d77bc518 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Use navigator instead of overlay as TickerProvider for ModalBottomSheet (#93499)

parent eabb7cbc
......@@ -508,7 +508,7 @@ class _ModalBottomSheetRoute<T> extends PopupRoute<T> {
_animationController = transitionAnimationController;
willDisposeAnimationController = false;
} else {
_animationController = BottomSheet.createAnimationController(navigator!.overlay!);
_animationController = BottomSheet.createAnimationController(navigator!);
}
return _animationController!;
}
......
......@@ -51,6 +51,43 @@ void main() {
FlutterError.onError = handler;
});
testWidgets('Disposing app while bottom sheet is disappearing does not crash', (WidgetTester tester) async {
late BuildContext savedContext;
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (BuildContext context) {
savedContext = context;
return Container();
},
),
),
);
await tester.pump();
expect(find.text('BottomSheet'), findsNothing);
// Bring up bottom sheet.
bool showBottomSheetThenCalled = false;
showModalBottomSheet<void>(
context: savedContext,
builder: (BuildContext context) => const Text('BottomSheet'),
).then<void>((void value) {
showBottomSheetThenCalled = true;
});
await tester.pumpAndSettle();
expect(find.text('BottomSheet'), findsOneWidget);
expect(showBottomSheetThenCalled, isFalse);
// Start closing animation of Bottom sheet.
tester.state<NavigatorState>(find.byType(Navigator)).pop();
await tester.pump();
// Dispose app by replacing it with a container. This shouldn't crash.
await tester.pumpWidget(Container());
});
testWidgets('Tapping on a modal BottomSheet should not dismiss it', (WidgetTester tester) async {
late BuildContext savedContext;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment