showSysConfirm static method
显示系统原生确认对话框
title 标题
message 内容
cancelLabelText 取消按钮文本
okLabelText OK按钮文本
onCancel 取消回调
onConfirm 确认回调(必填)
用法示例
PPAlert.showSysConfirm(
title: "确定要删除?",
onConfirm: () { print("删除!"); },
onCancel: () { print("取消!"); },
);
Implementation
static Future<void> showSysConfirm({
String title = 'Confirm',
String message = 'Do you want to do it?',
String cancelLabelText = 'Cancel',
String okLabelText = 'OK',
Function? onCancel,
required Function onConfirm,
}) async {
if (isAlerted) {
return;
}
isAlerted = true;
final result = await showOkCancelAlertDialog(
context: Get.context!,
title: title,
message: message,
cancelLabel: cancelLabelText,
okLabel: okLabelText,
barrierDismissible: false,
defaultType: OkCancelAlertDefaultType.cancel,
);
isAlerted = false;
if (result == OkCancelResult.ok) {
onConfirm();
} else if (result == OkCancelResult.cancel) {
if (onCancel != null) {
onCancel();
}
}
}