confirmationDialog function

Future<bool> confirmationDialog(
  1. BuildContext context,
  2. String message,
  3. String confirmText,
  4. String cancelText,
)

Dialog for confirmation Shows a dialog with given question and returns a confirmation bool

Implementation

Future<bool> confirmationDialog(BuildContext context, String message,
    String confirmText, String cancelText) async {
  bool? res = await showDialog<bool>(
    context: context,
    barrierDismissible: true,
    builder: (BuildContext context) {
      return SimpleDialog(
        title: Text(message),
        shape: const RoundedRectangleBorder(
            borderRadius: BorderRadius.all(Radius.circular(20))),
        children: <Widget>[
          FittedBox(
            child: ConfirmDenyButtons(
                confirm: () {
                  Navigator.of(context).pop(true);
                },
                deny: () {
                  Navigator.of(context).pop(false);
                },
                denyText: cancelText,
                confirmText: confirmText),
          ),
        ],
      );
    },
  );
  return res ?? false;
}