showModalActionSheet<T> function
- @useResult
- required BuildContext context,
- String? title,
- String? message,
- List<
SheetAction< actions = const [],T> > - String? cancelLabel,
- AdaptiveStyle? style,
- bool isDismissible = true,
- bool canPop = true,
- MaterialModalActionSheetConfiguration? materialConfiguration,
- PopInvokedWithResultCallback<
T> ? onPopInvokedWithResult, - AdaptiveDialogBuilder? builder,
- RouteSettings? routeSettings,
- AdaptiveSelectionMode? selectionMode,
Show modal action sheet, whose appearance is adaptive according to platform
style specifies the style of the sheet.
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
@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,
bool canPop = true,
MaterialModalActionSheetConfiguration? materialConfiguration,
PopInvokedWithResultCallback<T>? onPopInvokedWithResult,
AdaptiveDialogBuilder? builder,
RouteSettings? routeSettings,
AdaptiveSelectionMode? selectionMode,
}) {
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,
selectionMode: selectionMode,
);
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,
selectionMode: selectionMode,
);
return builder == null ? sheet : builder(context, sheet);
},
);
}