CustomNetworkWarningToast static method

void CustomNetworkWarningToast({
  1. required BuildContext context,
  2. bool? isRetryCallback,
  3. dynamic retryCallbak()?,
})

Implementation

static void CustomNetworkWarningToast(
    {required BuildContext context, bool? isRetryCallback, Function()? retryCallbak}) async {
  try {
    if (isflushLoadingbar == false) {
      Navigator.of(context).maybePop();
    }
    await flushWaringbar?.dismiss();
    if (isflushWaringbar) {
      isflushWaringbar = false;
      bool isCall = true;
      flushWaringbar = await Flushbar(
              flushbarStyle: FlushbarStyle.FLOATING,
              dismissDirection: FlushbarDismissDirection.HORIZONTAL,
              backgroundColor: Colors.black87.withOpacity(0.6),
              flushbarPosition: FlushbarPosition.BOTTOM,
              messageText: CustomTextDefaultField(
                  label: "Không có kết nối mạng", color: Colors.white, maxLine: 2),
              isDismissible: true,
              blockBackgroundInteraction: true,
              duration: const Duration(milliseconds: 8000),
              animationDuration: const Duration(milliseconds: 250),
              margin: EdgeInsets.only(bottom: 10),
              leftBarIndicatorColor: Colors.red,
              mainButton: isRetryCallback == true
                  ? TextButton(
                      onPressed: () async {
                        await flushWaringbar?.dismiss();
                        if (retryCallbak != null && isCall) {
                          CustomLoadingToast(context: context);
                          isCall = false;
                          retryCallbak();
                        }
                      },
                      child: Column(
                        mainAxisSize: MainAxisSize.min,
                        children: [
                          Icon(
                            CupertinoIcons.restart,
                            color: Colors.white,
                          ),
                          SpaceH2(),
                          Text(
                            "Thử lại",
                            style: TextStyle(
                                color: Colors.white,
                                fontSize: Sizes.TEXT_SIZE_12,
                                fontStyle: FontStyle.normal),
                            maxLines: 1,
                          ),
                        ],
                      ),
                    )
                  : Container(),
              icon: Icon(CupertinoIcons.wifi_exclamationmark))
          .show(context)
          .then((value) {
        isflushWaringbar = true;
        return null;
      });
    }
  } catch (e) {}
}