showNAlertDialog<T> function
Future<T?>
showNAlertDialog<T>({
- required BuildContext context,
- required String title,
- String? message,
- String? confirmLabel = 'OK',
- String? cancelLabel,
- T? confirmValue,
- T? cancelValue,
- VoidCallback? onConfirm,
- Color? confirmColor,
- AppFeedbackType type = AppFeedbackType.info,
- bool barrierDismissible = true,
Shows an alert dialog and returns the pressed action.
Implementation
Future<T?> showNAlertDialog<T>({
required BuildContext context,
required String title,
String? message,
String? confirmLabel = 'OK',
String? cancelLabel,
T? confirmValue,
T? cancelValue,
VoidCallback? onConfirm,
Color? confirmColor,
AppFeedbackType type = AppFeedbackType.info,
bool barrierDismissible = true,
}) =>
showDialog<T>(
context: context,
barrierDismissible: barrierDismissible,
child: Dialog(
title: title,
subtitle: message,
icon: _iconFor(type),
actions: <Widget>[
if (cancelLabel != null)
TextButton(
onPressed: () => Navigator.of(context).pop(cancelValue),
child: Text(cancelLabel),
),
FilledButton(
onPressed: () {
onConfirm?.call();
Navigator.of(context).pop(confirmValue);
},
style: FilledButton.styleFrom(
backgroundColor: confirmColor ?? AppColors.forFeedback(type),
),
child: Text(confirmLabel ?? 'OK'),
),
],
),
);