showPopup static method

void showPopup({
  1. required bool isError,
  2. required BuildContext context,
  3. required Function onClose,
  4. required String buttonTestKey,
  5. required String buttonName,
  6. Function? beforePopup,
  7. String? title,
  8. String? msg,
})

Implementation

static void showPopup(
    {required bool isError,
    required BuildContext context,
    required Function onClose,
    required String buttonTestKey,
    required String buttonName,
    Function? beforePopup,
    String? title,
    String? msg}) {
  if (_isPopupShowing) return;
  _isPopupShowing = true;
  if (beforePopup != null) beforePopup();
  showDialog(
    context: context,
    barrierDismissible: false,
    builder: (context) {
      return AlertDialog(
        icon: isError
            ? TkfIcons.failed(color: kErrorColor)
            : TkfIcons.success(),
        title: title != null
            ? Text(title,
                style: kTitleStyleDark.copyWith(fontWeight: FontWeight.bold))
            : null,
        contentPadding:
            const EdgeInsets.only(left: 23, right: 23, top: 15, bottom: 15),
        content: msg != null
            ? Text(msg,
                style: kTextStyle14o80.copyWith(fontSize: 16),
                textAlign: TextAlign.center)
            : null,
        actions: [
          TkfPopUpButton(
            testKey: Key(buttonTestKey),
            name: buttonName,
            onPress: () {
              _isPopupShowing = false;
              onClose();
            },
          )
        ],
      );
    },
  );
}