show static method
Future<void>
show(
- BuildContext context, {
- required String title,
- required String description,
- String? confirmText,
- String? cancelText,
- VoidCallback? onConfirm,
- VoidCallback? onCancel,
- Widget? icon,
- ModulaDialogType type = ModulaDialogType.info,
- bool barrierDismissible = true,
- TextStyle? titleStyle,
- TextStyle? descriptionStyle,
- ShapeBorder? shape,
- Color? backgroundColor,
- double elevation = 24.0,
- EdgeInsetsGeometry? contentPadding,
- Widget? customContent,
Implementation
static Future<void> show(
BuildContext context, {
required String title,
required String description,
String? confirmText,
String? cancelText,
VoidCallback? onConfirm,
VoidCallback? onCancel,
Widget? icon,
ModulaDialogType type = ModulaDialogType.info,
bool barrierDismissible = true,
TextStyle? titleStyle,
TextStyle? descriptionStyle,
ShapeBorder? shape,
Color? backgroundColor,
double elevation = 24.0,
EdgeInsetsGeometry? contentPadding,
Widget? customContent,
}) async {
final resolvedIcon = icon ?? _getDefaultIcon(type);
await showDialog<void>(
context: context,
barrierDismissible: barrierDismissible,
builder:
(context) => AlertDialog(
backgroundColor: backgroundColor,
elevation: elevation,
shape:
shape ??
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
contentPadding: contentPadding ?? const EdgeInsets.all(20),
title: Row(
children: [
if (resolvedIcon != null) ...[
resolvedIcon,
const SizedBox(width: 12),
],
Expanded(
child: Text(
title,
style: titleStyle ?? Theme.of(context).textTheme.titleLarge,
),
),
],
),
content:
customContent ??
Text(
description,
style:
descriptionStyle ??
Theme.of(context).textTheme.bodyMedium,
),
actions: [
if (cancelText != null)
TextButton(
onPressed: () {
Navigator.of(context).pop();
onCancel?.call();
},
child: Text(cancelText),
),
if (confirmText != null)
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
onConfirm?.call();
},
child: Text(confirmText),
),
],
),
);
}