BaseActionSheet class
Base wrapper for ActionSheet with native iOS support and cross-platform compatibility
Provides true native iOS action sheets via platform channels with fallback to Material Design bottom sheets on other platforms. Uses the cupertino_native package for authentic native iOS action sheet experience.
Features:
- Native iOS action sheets with platform-specific styling
- Material Design bottom sheet fallback for non-iOS platforms
- Consistent API across platforms
- Support for action styles (default, cancel, destructive)
- Cancel button handling
- Follows Apple HIG guidelines for action sheets
- Automatic platform-specific conversion of actions
Apple HIG best practices:
- Use action sheets to offer choices related to an intentional action
- Keep titles short (single line when possible)
- Provide a message only if necessary
- Make destructive choices visually prominent (place at top)
- Always provide a Cancel button that lets people reject destructive actions
- Place Cancel button at the bottom
- Avoid letting action sheets scroll (too many buttons)
Updated: 2024.10.25
Example:
BaseActionSheet.show(
context: context,
title: 'Delete Draft?',
message: 'This action cannot be undone.',
actions: [
BaseActionSheetAction(
title: 'Delete Draft',
style: BaseActionSheetActionStyle.destructive,
onPressed: () => deleteDraft(),
),
BaseActionSheetAction(
title: 'Save Draft',
onPressed: () => saveDraft(),
),
],
cancelAction: BaseActionSheetAction(
title: 'Cancel',
style: BaseActionSheetActionStyle.cancel,
),
);
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
show(
{required BuildContext context, String? title, String? message, required List< BaseActionSheetAction> actions, BaseActionSheetAction? cancelAction, BaseParam? cupertino, BaseParam? material}) → Future<int?> - Shows a native action sheet
-
showConfirmation(
{required BuildContext context, String? title, String? message, String confirmTitle = 'Delete', String cancelTitle = 'Cancel', VoidCallback? onConfirm, BaseParam? cupertino, BaseParam? material}) → Future< bool> - Shows a simple confirmation action sheet with delete/cancel options