AlertDialogHelper class
A common alert dialog function that provides a reusable way to show alert dialogs with customizable icon, text constraints, markdown content, and flexible button options.
Usage Examples:
Basic usage with auto-sizing (no constraints):
ui.AlertDialogHelper.showWarning(
context: context,
markdownText: '**Warning!** This action cannot be undone.',
onConfirm: () => print('Confirmed'),
// Dialog will automatically size to fit content
);
Centered text with custom constraints:
ui.AlertDialogHelper.showInfo(
context: context,
markdownText: '**Centered Information**\n\nThis text is centered.',
textAlignment: TextAlign.center,
textConstraints: BoxConstraints(
minWidth: 400.0,
maxWidth: 600.0,
minHeight: 200.0,
maxHeight: 500.0,
),
);
Full width dialog that fills available space:
ui.AlertDialogHelper.showWarning(
context: context,
markdownText: '# Full Width Dialog\n\nContent that fills the space.',
textConstraints: BoxConstraints(
minWidth: 500.0,
maxWidth: 800.0,
minHeight: 300.0,
maxHeight: 600.0,
),
textAlignment: TextAlign.center,
);
Compact dialog with minimal space:
ui.AlertDialogHelper.showError(
context: context,
markdownText: '**Compact Error**\n\nMinimal constraints.',
textConstraints: BoxConstraints(
minWidth: 200.0,
maxWidth: 300.0,
minHeight: 50.0,
maxHeight: 150.0,
),
);
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<
T> ({required BuildContext context, IconData? icon, Color? iconColor, double? iconSize, required String markdownText, BoxConstraints? textConstraints, TextAlign textAlignment = TextAlign.start, String? cancelText, String? confirmText, String? dismissText, VoidCallback? onCancel, VoidCallback? onConfirm, VoidCallback? onDismiss, bool barrierDismissible = true}) → Future< T?> - Shows an alert dialog with the specified parameters.
-
showError(
{required BuildContext context, required String markdownText, IconData? icon, Color? iconColor, String? dismissText, VoidCallback? onDismiss, bool barrierDismissible = true, BoxConstraints? textConstraints, TextAlign textAlignment = TextAlign.start}) → Future< void> - Shows an error alert dialog with just a dismiss button.
-
showInfo(
{required BuildContext context, required String markdownText, IconData? icon, Color? iconColor, String? dismissText, VoidCallback? onDismiss, bool barrierDismissible = true, BoxConstraints? textConstraints, TextAlign textAlignment = TextAlign.start}) → Future< void> - Shows a simple alert dialog with just a dismiss button.
-
showWarning(
{required BuildContext context, required String markdownText, IconData? icon, Color? iconColor, String? cancelText, String? confirmText, VoidCallback? onCancel, VoidCallback? onConfirm, bool barrierDismissible = true, BoxConstraints? textConstraints, TextAlign textAlignment = TextAlign.start}) → Future< void> - Shows a warning alert dialog with cancel and confirm buttons.