show static method
Future<int?>
show({
- required BuildContext context,
- String? title,
- String? message,
- required List<
BaseActionSheetAction> actions, - BaseActionSheetAction? cancelAction,
- BaseParam? cupertino,
- BaseParam? material,
Shows a native action sheet
context: Build context for showing the sheettitle: Title text (keep short, ideally single line)message: Optional message for additional contextactions: List of actions to display (destructive actions should be first)cancelAction: Optional cancel action (recommended, especially for destructive actions)cupertino: Cupertino-specific parametersmaterial: Material-specific parameters
Returns the index of the action that was tapped, or null if cancelled
Implementation
static Future<int?> show({
required BuildContext context,
String? title,
String? message,
required List<BaseActionSheetAction> actions,
BaseActionSheetAction? cancelAction,
BaseParam? cupertino,
BaseParam? material,
}) async {
if (actions.isEmpty) {
throw ArgumentError('Actions list cannot be empty');
}
// Determine which platform implementation to use
final useCupertino = _shouldUseCupertino(context, cupertino, material);
if (useCupertino) {
// Convert BaseActionSheetAction to CNActionSheetAction for iOS
final cnActions = actions.map((action) => action.toCNActionSheetAction()).toList();
final cnCancelAction = cancelAction?.toCNActionSheetAction();
return await _showCupertinoNativeActionSheet(
title: title,
message: message,
actions: cnActions,
cancelAction: cnCancelAction,
);
} else {
return await _showMaterialBottomSheet(
context: context,
title: title,
message: message,
actions: actions,
cancelAction: cancelAction,
);
}
}