CNActionSheet class
Native iOS Action Sheet
An action sheet is a modal view that presents choices related to an action people initiate.
Best practices from Apple HIG:
- 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)
Example:
CNActionSheet.show(
context: context,
title: 'Delete Draft?',
message: 'This action cannot be undone.',
actions: [
CNActionSheetAction(
title: 'Delete Draft',
style: CNActionSheetButtonStyle.destructive,
onPressed: () => deleteDraft(),
),
CNActionSheetAction(
title: 'Save Draft',
onPressed: () => saveDraft(),
),
],
cancelAction: CNActionSheetAction(
title: 'Cancel',
style: CNActionSheetButtonStyle.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< CNActionSheetAction> actions, CNActionSheetAction? cancelAction}) → Future<int?> - Shows a native iOS action sheet
-
showConfirmation(
{required BuildContext context, String? title, String? message, String confirmTitle = 'Delete', String cancelTitle = 'Cancel', VoidCallback? onConfirm}) → Future< bool> - Shows a simple confirmation action sheet with delete/cancel options