dialogWithOptions static method

Future<void> dialogWithOptions({
  1. required BuildContext context,
  2. required String title,
  3. required String message,
  4. bool barrierDismissible = true,
  5. String textLeftButton = 'OK',
  6. String textRightButton = 'Cancel',
  7. Function? onPressedLeftButton,
  8. Function? onPressedRightButton,
  9. DestructiveAction destructiveAction = DestructiveAction.right,
  10. DefaultAction defaultAction = DefaultAction.none,
  11. Color androidDestructiveColor = Colors.red,
  12. bool popByDefault = true,
})

Here is the dialog with options, it's useful if you want to pop up a dialog where you can choose between two options. One of them can be set as destructive action.

Implementation

static Future<void> dialogWithOptions({
  required BuildContext context,
  required String title,
  required String message,
  bool barrierDismissible = true,
  String textLeftButton = 'OK',
  String textRightButton = 'Cancel',
  Function? onPressedLeftButton,
  Function? onPressedRightButton,
  DestructiveAction destructiveAction = DestructiveAction.right,
  DefaultAction defaultAction = DefaultAction.none,
  Color androidDestructiveColor = Colors.red,
  bool popByDefault = true,
}) async =>
    await showDialog(
        context: context,
        barrierDismissible: barrierDismissible,
        builder: (context) {
          if (Theme.of(context).platform == TargetPlatform.iOS) {
            return CupertinoDialogWithOptions(
              title: title,
              message: message,
              textLeftButton: textLeftButton,
              textRightButton: textRightButton,
              onPressedLeftButton: onPressedLeftButton,
              onPressedRightButton: onPressedRightButton,
              destructiveAction: destructiveAction,
              defaultAction: defaultAction,
              popByDefault: popByDefault,
            );
          }
          return MaterialDialogWithOptions(
            title: title,
            message: message,
            textLeftButton: textLeftButton,
            textRightButton: textRightButton,
            onPressedLeftButton: onPressedLeftButton,
            onPressedRightButton: onPressedRightButton,
            destructiveAction: destructiveAction,
            defaultAction: defaultAction,
            popByDefault: popByDefault,
            androidDestructiveColor: androidDestructiveColor,
          );
        });