updateProfileImage method
dynamic
updateProfileImage(
- String path, {
- bool update = false,
})
Implementation
updateProfileImage(String path, {bool update = false}) async {
debugPrint("Profile Controller updateProfileImage path $path");
if (await AppUtils.isNetConnected()) {
loading.value = true;
debugPrint("Profile Controller showing loader");
// if(checkFileUploadSize(path, Constants.mImage)) {
showLoader();
debugPrint("Profile Controller updateMyProfileImage");
Mirrorfly.updateMyProfileImage(
image: path,
flyCallback: (FlyResponse response) {
if (response.isSuccess) {
LogMessage.d("updateMyProfileImage", response.data);
loading.value = false;
var data = json.decode(response.data);
imagePathNew(imagePath.value);
imagePath.value = Constants.emptyString;
userImgUrl.value = data['data']['image'];
SessionManagement.setUserImage(data['data']['image'].toString());
hideLoader();
if (update) {
save();
}
} else {
toToast(getTranslated("profileImageUpdateFailed"));
debugPrint(
"Profile Update on error--> ${response.exception.toString()}");
loading.value = false;
hideLoader();
}
});
/*.then((value) {
LogMessage.d("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();
if (update) {
save();
}
}).catchError((onError) {
debugPrint("Profile Update on error--> ${onError.toString()}");
loading.value = false;
hideLoader();
});*/
// }else{
// toToast("Image Size exceeds 10MB");
// }
} else {
toToast(getTranslated("noInternetConnection"));
}
}