showConfirmationDialog function
- BuildContext context, {
- required String title,
- required String message,
- String? confirmLabel,
- String? cancelLabel,
Shows a confirmation dialog with the given title and message to the user.
The dialog will have a confirm and a cancel button and will return true if the confirm button is pressed and false if the cancel button is pressed.
Implementation
Future<bool> showConfirmationDialog(
BuildContext context, {
required String title,
required String message,
String? confirmLabel,
String? cancelLabel,
}) async {
final result = await showGenericDialog<bool>(
context,
title: title,
content: Text(message),
shrinkWrapWidth: true,
actions: [
PrimaryDialogAction(
label: confirmLabel ?? context.t.global_confirm,
onPressed: (context) {
Navigator.of(context).pop(true);
},
),
SecondaryDialogAction(
label: cancelLabel ?? context.t.global_cancel,
onPressed: (context) {
Navigator.of(context).pop(false);
},
),
],
);
return result ?? false;
}