showAlertView function
Future<bool>
showAlertView({
- required BuildContext context,
- String? title,
- String? message,
- String? confirmTitle,
- String? cancelTitle,
- VoidCallback? onConfirm,
- VoidCallback? onCancel,
- bool isDestructiveAction = false,
Implementation
Future<bool> showAlertView({
required BuildContext context,
String? title,
String? message,
String? confirmTitle,
String? cancelTitle,
VoidCallback? onConfirm,
VoidCallback? onCancel,
bool isDestructiveAction = false,
}) async {
return await showCupertinoDialog(
context: context,
builder: (BuildContext context) {
return CupertinoAlertDialog(
title: title != null ? Text(title) : null,
content: message != null ? Text(message) : null,
actions: [
CupertinoDialogAction(
child: Text(cancelTitle ?? AlertView.defaultCancelTitle),
onPressed: () {
Navigator.pop(context, false);
if (onCancel != null) {
onCancel();
}
},
),
if (confirmTitle != null || onConfirm != null)
CupertinoDialogAction(
isDestructiveAction: isDestructiveAction,
isDefaultAction: true,
child: Text(confirmTitle ?? AlertView.defaultConfirmTitle),
onPressed: () {
Navigator.pop(context, true);
if (onConfirm != null) {
onConfirm();
}
},
),
],
);
},
);
}