showSysConfirm static method

void showSysConfirm({
  1. String title = 'Confirm',
  2. String message = 'Do you want to do it?',
  3. String cancelLabelText = 'Cancel',
  4. String okLabelText = 'OK',
  5. Function? onCancel,
  6. required Function onConfirm,
})

显示系统确认对话框

Implementation

static 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,
  );
  if (result == OkCancelResult.ok) {
    isAlerted = false;
    onConfirm();
  } else if (result == OkCancelResult.cancel) {
    isAlerted = false;
    if (onCancel != null) {
      onCancel();
    }
  }
}