showGlassActionSheet<T> function

Future<T?> showGlassActionSheet<T>({
  1. required BuildContext context,
  2. Widget? title,
  3. Widget? message,
  4. required List<GlassActionSheetAction> actions,
  5. GlassActionSheetAction? cancel,
  6. bool barrierDismissible = true,
  7. String semanticLabel = 'Actions',
  8. bool useRootNavigator = true,
})

Shows an action sheet that springs up from the bottom over a dimmed page, as iOS's do: a group of actions under an optional title and message, and a cancel button of its own below them.

Resolves with the chosen action's result, or null when the sheet is dismissed with a tap outside it or the Escape key.

Implementation

Future<T?> showGlassActionSheet<T>({
  required BuildContext context,
  Widget? title,
  Widget? message,
  required List<GlassActionSheetAction> actions,
  GlassActionSheetAction? cancel,
  bool barrierDismissible = true,
  String semanticLabel = 'Actions',
  bool useRootNavigator = true,
}) {
  final carried = GlassOverlayContext.of(context);
  final reduceMotion = MediaQuery.maybeDisableAnimationsOf(context) ?? false;
  return Navigator.of(context, rootNavigator: useRootNavigator).push<T>(
    _GlassActionSheetRoute<T>(
      carried: carried,
      dismissible: barrierDismissible,
      reduceMotion: reduceMotion,
      sheet: GlassActionSheet(
        title: title,
        message: message,
        actions: actions,
        cancel: cancel,
        semanticLabel: semanticLabel,
      ),
    ),
  );
}