save method
Implementation
Future<void> save(
{bool frmImage = false, required BuildContext context}) async {
// if (await askStoragePermission(context)) {
if (await validation()) {
loading.value = true;
if (context.mounted) showLoader(context);
if (imagePath.value.isNotEmpty) {
debugPrint("profile image update");
if (context.mounted) {
updateProfileImage(
path: imagePath.value, update: true, context: context);
} else {
mirrorFlyLog("Profile Controller", "Context is not mounted");
}
} else {
if (await AppUtils.isNetConnected()) {
debugPrint("profile update");
var formattedNumber =
await lib_phone_number.parse(profileMobile.text);
debugPrint("parse-----> $formattedNumber");
var unformatted = formattedNumber[
'national_number']; //profileMobile.text.replaceAll(" ", Constants.emptyString).replaceAll("+", Constants.emptyString);
// var unformatted = profileMobile.text;
debugPrint('unformatted : $unformatted');
Mirrorfly.updateMyProfile(
name: profileName.text.toString(),
email: profileEmail.text.toString(),
mobile: unformatted,
status: profileStatus.value.toString(),
image: userImgUrl.value.isEmpty ? null : userImgUrl.value,
flyCallback: (FlyResponse response) {
loading.value = false;
hideLoader(context);
if (response.isSuccess) {
var data = profileUpdateFromJson(response.data);
if (data.status != null) {
toToast(frmImage
? AppConstants.removedProfileImage
: data.message.toString());
if (data.status!) {
changed(false);
var userProfileData = ProData(
email: profileEmail.text.toString(),
image: userImgUrl.value,
mobileNumber: unformatted,
nickName: profileName.text,
name: profileName.text,
status: profileStatus.value);
SessionManagement.setCurrentUser(userProfileData);
}
}
} else {
toToast(AppConstants.unableToUpdateProfile);
}
});
} else {
loading(false);
if (context.mounted) hideLoader(context);
toToast(AppConstants.noInternetConnection);
}
}
}
// }
}