showConfirmationDialog function

Future<bool> showConfirmationDialog({
  1. required BuildContext context,
  2. required ConfirmationDialogTexts texts,
  3. ConfirmationDialogOptions options = const ConfirmationDialogOptions(),
})

Opens a confirmation dialog with a title and a messageString inside the application.

The actions of the button are set in the onCancel and onConfirm parameters

Implementation

Future<bool> showConfirmationDialog({
  required BuildContext context,
  required ConfirmationDialogTexts texts,
  ConfirmationDialogOptions options = const ConfirmationDialogOptions(),
}) async {
  final result = await showDialog<bool>(
    context: context,
    builder: (context) => ScaffoldMessenger(
      child: Builder(
        builder: (context) => ConfirmationDialog(
          texts: texts,
          options: options,
        ),
      ),
    ),
  );

  if (result == null) {
    return false;
  }

  return result;
}