showConfirmationDialog method

  1. @override
void showConfirmationDialog({
  1. required BuildContext context,
  2. required String title,
  3. required String message,
  4. required String confirmText,
  5. required String cancelText,
  6. required void onConfirm(
    1. bool
    ),
})
override

Shows a confirmation dialog.

title The title of the dialog. message The message to display. confirmText The text for the confirm button. cancelText The text for the cancel button. onConfirm Callback when the user confirms (receives true if confirmed).

Implementation

@override
void showConfirmationDialog({
  required BuildContext context,
  required String title,
  required String message,
  required String confirmText,
  required String cancelText,
  required void Function(bool) onConfirm,
}) {
  showDialog(
    context: context,
    builder: (context) => AlertDialog(
      title: Text(title),
      content: Text(message),
      actions: [
        TextButton(
          onPressed: () {
            Navigator.of(context).pop();
            onConfirm(false);
          },
          child: Text(cancelText),
        ),
        TextButton(
          onPressed: () {
            Navigator.of(context).pop();
            onConfirm(true);
          },
          child: Text(confirmText),
        ),
      ],
    ),
  );
}