Use navigator instead of overlay as TickerProvider for ModalBottomSheet (#93499)
This commit is contained in:
committed by
GitHub
parent
eabb7cbc34
commit
d77bc51856
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user