showModalActionSheet<T> function

  1. @useResult
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,
  7. bool isDismissible = true,
  8. bool useRootNavigator = true,
  9. MaterialModalActionSheetConfiguration? materialConfiguration,
  10. bool canPop = true,
  11. PopInvokedWithResultCallback<T>? onPopInvokedWithResult,
  12. AdaptiveDialogBuilder? builder,
  13. RouteSettings? routeSettings,
})

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.
@useResult
Future<T?> showModalActionSheet<T>({
  required BuildContext context,
  String? title,
  String? message,
  List<SheetAction<T>> actions = const [],
  String? cancelLabel,
  AdaptiveStyle? style,
  bool isDismissible = true,
  bool useRootNavigator = true,
  MaterialModalActionSheetConfiguration? materialConfiguration,
  bool canPop = true,
  PopInvokedWithResultCallback<T>? onPopInvokedWithResult,
  AdaptiveDialogBuilder? builder,
  RouteSettings? routeSettings,
}) {
  void pop({required BuildContext context, required T? key}) => Navigator.of(
        context,
        rootNavigator: useRootNavigator,
      ).pop(key);

  final theme = Theme.of(context);
  final adaptiveStyle = style ?? AdaptiveDialog.instance.defaultStyle;
  return adaptiveStyle.isMaterial(theme)
      ? showModalBottomSheet(
          context: context,
          isScrollControlled: materialConfiguration != null,
          isDismissible: isDismissible,
          useRootNavigator: useRootNavigator,
          routeSettings: routeSettings,
          builder: (context) {
            final sheet = MaterialModalActionSheet(
              onPressed: (key) => pop(context: context, key: key),
              title: title,
              message: message,
              actions: actions,
              materialConfiguration: materialConfiguration,
              canPop: canPop,
              onPopInvokedWithResult: onPopInvokedWithResult,
            );
            return builder == null ? sheet : builder(context, sheet);
          },
        )
      : showCupertinoModalPopup(
          context: context,
          useRootNavigator: useRootNavigator,
          routeSettings: routeSettings,
          builder: (context) {
            final sheet = CupertinoModalActionSheet(
              onPressed: (key) => pop(context: context, key: key),
              title: title,
              message: message,
              actions: actions,
              cancelLabel: cancelLabel,
              canPop: canPop,
              onPopInvokedWithResult: onPopInvokedWithResult,
            );
            return builder == null ? sheet : builder(context, sheet);
          },
        );
}