dialogWithOptions static method
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,
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,
);
});