BaseAlert class

BaseAlert - Cross-platform native alert dialogs

Uses native iOS UIAlertController via platform channels for iOS - provides authentic iOS alert dialogs with native styling and behavior. Uses Material AlertDialog for Android and other platforms.

Features:

  • Native iOS/macOS alert dialogs via UIAlertController (platform channels)
  • Material Design fallback for non-iOS platforms
  • Consistent API across platforms
  • Support for action styles (default, cancel, destructive)
  • Preferred action highlighting
  • Convenience methods for common alert patterns
  • Automatic platform-specific conversion of actions

Example:

await BaseAlert.show(
  context: context,
  title: 'Delete Photo',
  message: 'Are you sure you want to delete this photo?',
  actions: [
    BaseAlertAction(
      title: 'Cancel',
      style: BaseAlertActionStyle.cancel,
    ),
    BaseAlertAction(
      title: 'Delete',
      style: BaseAlertActionStyle.destructive,
      onPressed: () {
        // Perform delete action
      },
    ),
  ],
);

Updated: 2024.10.25 - Renamed from BaseCNAlert for consistency

Constructors

BaseAlert()

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, required String title, String? message, required List<BaseAlertAction> actions, int? preferredActionIndex, BaseParam? cupertino, BaseParam? material}) → Future<int?>
Shows a native alert dialog.
showConfirmation({required BuildContext context, required String title, String? message, String confirmTitle = 'Confirm', VoidCallback? onConfirm, BaseParam? cupertino, BaseParam? material}) → Future<bool>
Shows a confirmation alert with Cancel and Confirm buttons.
showDestructiveConfirmation({required BuildContext context, required String title, String? message, required String destructiveTitle, VoidCallback? onDestroy, BaseParam? cupertino, BaseParam? material}) → Future<bool>
Shows a destructive confirmation alert.
showInfo({required BuildContext context, required String title, String? message, BaseParam? cupertino, BaseParam? material}) → Future<void>
Shows a simple informational alert with an OK button.