blockUser method

dynamic blockUser(
  1. BuildContext context
)

Implementation

blockUser(BuildContext context) {
  Future.delayed(const Duration(milliseconds: 100), () async {
    Helper.showAlert(
        message: "${AppConstants.youWantBlock} ${profile.getName()}?",
        actions: [
          TextButton(
              onPressed: () {
                // Get.back();
                Navigator.pop(context);
              },
              child: Text(
                AppConstants.cancel.toUpperCase(),
                style:
                    TextStyle(color: MirrorflyUikit.getTheme?.primaryColor),
              )),
          TextButton(
              onPressed: () async {
                if (await AppUtils.isNetConnected()) {
                  // Get.back();
                  if (context.mounted) Navigator.pop(context);
                  if (context.mounted) {
                    Helper.showLoading(
                        message: AppConstants.blockingUser, buildContext: context);
                  }
                  Mirrorfly.blockUser(profile.jid!).then((value) {
                    debugPrint(value);
                    profile.isBlocked = true;
                    isBlocked(true);
                    profile_.refresh();
                    saveUnsentMessage();
                    Helper.hideLoading(context: context);
                    toToast('${profile.getName()} ${AppConstants.hasBlocked}');
                  }).catchError((error) {
                    Helper.hideLoading(context: context);
                    debugPrint(error);
                  });
                } else {
                  toToast(AppConstants.noInternetConnection);
                }
              },
              child: Text(
                AppConstants.block.toUpperCase(),
                style:
                    TextStyle(color: MirrorflyUikit.getTheme?.primaryColor),
              )),
        ],
        context: context);
  });
}