showExpressiveBottomSheet<T> function

Future<T?> showExpressiveBottomSheet<T>(
  1. BuildContext context, {
  2. required WidgetBuilder builder,
  3. bool skipPartiallyExpanded = false,
  4. bool useRootNavigator = true,
  5. ExpressiveComponentThemeData? style,
})

Shows builder's content in a modal bottom sheet (Material's showModalBottomSheet, Compose's ModalBottomSheet), raised from code without a route of the app's router: the same scrim, sheet and back as ExpressiveSheetPage, on the root navigator by default. The route keeps the themes where it was raised (InheritedTheme.capture), so a subtree's theme reaches a sheet raised above it. Completes with the value the sheet is popped with.

showExpressiveBottomSheet<void>(context, builder: (context) => const ExpressiveListTile(title: Text('Share')))

Implementation

Future<T?> showExpressiveBottomSheet<T>(
  BuildContext context, {
  required WidgetBuilder builder,
  bool skipPartiallyExpanded = false,
  bool useRootNavigator = true,
  ExpressiveComponentThemeData? style,
}) {
  final navigator = Navigator.of(context, rootNavigator: useRootNavigator);
  return navigator.push<T>(
    _ModalSheetRoute<T>(
      style: style,
      content: builder,
      skipPartiallyExpanded: skipPartiallyExpanded,
      motion: ExpressiveMotion.of(context),
      dismissLabel: Localizations.of<MaterialLocalizations>(
        context,
        MaterialLocalizations,
      )?.modalBarrierDismissLabel,
      capturedThemes: InheritedTheme.capture(
        from: context,
        to: navigator.context,
      ),
    ),
  );
}