updateProfileImage method

dynamic updateProfileImage({
  1. required String path,
  2. bool update = false,
  3. required BuildContext context,
})

Implementation

updateProfileImage({required String path, bool update = false, required BuildContext context}) async {
  if(await AppUtils.isNetConnected()) {
    loading.value = true;

    // if(checkFileUploadSize(path, Constants.mImage)) {
    if(context.mounted)showLoader(context);
      Mirrorfly.updateMyProfileImage(path).then((value) {
        mirrorFlyLog("updateMyProfileImage", value);
        loading.value = false;
        var data = json.decode(value);
        imagePath.value = Constants.emptyString;
        userImgUrl.value = data['data']['image'];
        SessionManagement.setUserImage(data['data']['image'].toString());
        hideLoader(context);
        if (update) {
          save(context: context);
        }
      }).catchError((onError) {
        debugPrint("Profile Update on error--> ${onError.toString()}");
        loading.value = false;
        hideLoader(context);
      });
    // }else{
    //   toToast("Image Size exceeds 10MB");
    // }
  }else{
    toToast(AppConstants.noInternetConnection);
  }

}