showCustomAlert static method

void showCustomAlert({
  1. required BuildContext context,
  2. required bool? status,
  3. required String title,
  4. required String desc,
  5. required String buttonText,
  6. required String? buttonTextSecondary,
  7. VoidCallback? action,
  8. VoidCallback? actionSecondary,
})

Implementation

static void showCustomAlert({
  required BuildContext context,
  required bool? status,
  required String title,
  required String desc,
  required String buttonText,
  required String? buttonTextSecondary,
  VoidCallback? action,
  VoidCallback? actionSecondary,
}) {
  Alert(
    context: context,
    type: status == null ? AlertType.warning : status == true ? AlertType.success : AlertType.error,
    title: title,
    desc: desc,
    style: const AlertStyle(animationType: AnimationType.grow),
    buttons: [
      DialogButton(
        onPressed: () {
          Navigator.of(context, rootNavigator: true).pop();
          action?.call();
        },
        width: 120,
        child: Text(
          buttonText,
          style: const TextStyle(color: Colors.white, fontSize: 20),
        ),
      ),
      if(buttonTextSecondary != null)
        DialogButton(
          color: Colors.grey,
          onPressed: () {
            Navigator.of(context, rootNavigator: true).pop();
            actionSecondary?.call();
          },
          width: 120,
          child: Text(
            buttonTextSecondary,
            style: const TextStyle(color: Colors.white, fontSize: 20),
          ),
        ),
    ],
  ).show();
}