confirmationDialog function

Future<bool> confirmationDialog(
  1. BuildContext context,
  2. String message,
  3. String confirmMessage,
  4. String cancelMessage, {
  5. Widget? textMessage,
  6. AsyncCallback? onPressedDeny,
  7. AsyncCallback? onPressedConfirm,
})

Confirmation dialog Shows a dialog with cancel and confirm buttons and returns a confirmation bool

Implementation

Future<bool> confirmationDialog(
  BuildContext context,
  String message,
  String confirmMessage,
  String cancelMessage, {
  Widget? textMessage,
  AsyncCallback? onPressedDeny,
  AsyncCallback? onPressedConfirm,
}) async {
  return await showDialog<bool>(
        context: context,
        barrierDismissible: true,
        builder: (BuildContext context) {
          return SimpleDialog(
            title: textMessage ?? Text(message),
            shape: const RoundedRectangleBorder(
                borderRadius: BorderRadius.all(Radius.circular(20))),
            children: <Widget>[
              FittedBox(
                  child: Padding(
                padding: const EdgeInsets.all(5),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    TextButton(
                      onPressed: onPressedDeny ??
                          () {
                            Navigator.of(context).pop(false);
                          },
                      child: Container(
                        padding: const EdgeInsets.all(8),
                        decoration: BoxDecoration(
                            color: Colors.red[600],
                            borderRadius: BorderRadius.circular(30)),
                        child: Row(
                          children: <Widget>[
                            const Icon(
                              Icons.cancel,
                              color: Colors.white,
                              size: 25,
                            ),
                            Text(
                              cancelMessage,
                              style: text,
                            ),
                          ],
                        ),
                      ),
                    ), //Deny Button
                    Padding(
                      padding: const EdgeInsets.only(left: 20),
                      child: TextButton(
                        onPressed: onPressedConfirm ??
                            () {
                              Navigator.of(context).pop(true);
                            },
                        child: Container(
                          padding: const EdgeInsets.all(10),
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(30),
                            color: Colors.green[600],
                          ),
                          child: Row(
                            children: <Widget>[
                              const Icon(
                                Icons.check_circle,
                                color: Colors.white,
                                size: 25,
                              ),
                              Text(
                                confirmMessage,
                                style: text,
                              ),
                            ],
                          ),
                        ),
                      ),
                    ), //Agree Button
                  ],
                ),
              )),
            ],
          );
        },
      ) ??
      false;
}