Unverified Commit 1c964797 authored by Fabusuyi Ayodeji's avatar Fabusuyi Ayodeji Committed by GitHub

expose route settings for showModalBottomSheet (#60640)

parent bb328088
......@@ -583,6 +583,10 @@ class _BottomSheetSuspendedCurve extends ParametricCurve<double> {
/// parameters can be passed in to customize the appearance and behavior of
/// modal bottom sheets.
///
/// The optional `routeSettings` parameter sets the [RouteSettings] of the modal bottom sheet
/// sheet. This is particularly useful in the case that a user wants to observe
/// [PopupRoute]s within a [NavigatorObserver].
///
/// Returns a `Future` that resolves to the value (if any) that was passed to
/// [Navigator.pop] when the modal bottom sheet was closed.
///
......@@ -648,6 +652,7 @@ Future<T> showModalBottomSheet<T>({
bool useRootNavigator = false,
bool isDismissible = true,
bool enableDrag = true,
RouteSettings routeSettings,
}) {
assert(context != null);
assert(builder != null);
......@@ -670,6 +675,7 @@ Future<T> showModalBottomSheet<T>({
isDismissible: isDismissible,
modalBarrierColor: barrierColor,
enableDrag: enableDrag,
settings: routeSettings,
));
}
......
......@@ -696,6 +696,38 @@ void main() {
// the BottomNavigationBar.
expect(tester.getBottomLeft(find.byType(BottomSheet)).dy, 600.0);
});
testWidgets('Verify that route settings can be set in the showModalBottomSheet',
(WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
const RouteSettings routeSettings =
RouteSettings(name: 'route_name', arguments: 'route_argument');
await tester.pumpWidget(MaterialApp(
home: Scaffold(
key: scaffoldKey,
body: const Center(child: Text('body')),
),
));
RouteSettings retrievedRouteSettings;
showModalBottomSheet<void>(
context: scaffoldKey.currentContext,
routeSettings: routeSettings,
builder: (BuildContext context) {
retrievedRouteSettings = ModalRoute.of(context).settings;
return Container(
child: const Text('BottomSheet'),
);
},
);
await tester.pump();
await tester.pump(const Duration(seconds: 1));
expect(retrievedRouteSettings, routeSettings);
});
}
class _TestPage extends StatelessWidget {
......
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