showModalActionSheet<T> function

Future<T?> showModalActionSheet<T>({
  1. required BuildContext context,
  2. String? title,
  3. String? message,
  4. List<SheetAction<T>> actions = const [],
  5. String? cancelLabel,
  6. AdaptiveStyle style = AdaptiveStyle.adaptive,
  7. bool isDismissible = true,
  8. bool useRootNavigator = true,
  9. MaterialModalActionSheetConfiguration? materialConfiguration,
})

Show modal action sheet, whose appearance is adaptive according to platform The isDismissible parameter only works for material style and it specifies whether the bottom sheet will be dismissed when user taps on the scrim.

Implementation

/// The [isDismissible] parameter only works for material style and it specifies
/// whether the bottom sheet will be dismissed when user taps on the scrim.
Future<T?> showModalActionSheet<T>({
  required BuildContext context,
  String? title,
  String? message,
  List<SheetAction<T>> actions = const [],
  String? cancelLabel,
  AdaptiveStyle style = AdaptiveStyle.adaptive,
  bool isDismissible = true,
  bool useRootNavigator = true,
  MaterialModalActionSheetConfiguration? materialConfiguration,
}) {
  void pop(T? key) => Navigator.of(
        context,
        rootNavigator: useRootNavigator,
      ).pop(key);
  final theme = Theme.of(context);
  return style.isCupertinoStyle(theme)
      ? showCupertinoModalPopup(
          context: context,
          useRootNavigator: useRootNavigator,
          builder: (context) => CupertinoModalActionSheet(
            onPressed: pop,
            title: title,
            message: message,
            actions: actions,
            cancelLabel: cancelLabel,
          ),
        )
      : showModalBottomSheet(
          context: context,
          isScrollControlled: materialConfiguration != null,
          isDismissible: isDismissible,
          useRootNavigator: useRootNavigator,
          builder: (context) => MaterialModalActionSheet(
            onPressed: pop,
            title: title,
            message: message,
            actions: actions,
            cancelLabel: cancelLabel,
            materialConfiguration: materialConfiguration,
          ),
        );
}