updateProfile method
Implementation
Future<void> updateProfile() async {
try {
isUpdating.value = true;
final current = profileData.value;
Map<String, dynamic> body = {};
if (fullNameController.text.trim() != (current?.fullName ?? "")) {
body["fullName"] = fullNameController.text.trim();
}
if (mobileController.text.trim() != (current?.mobile ?? "")) {
body["mobile"] = mobileController.text.trim();
}
if (organizationController.text.trim() != (current?.organization ?? "")) {
body["organization"] = organizationController.text.trim();
}
if (designationController.text.trim() != (current?.designation ?? "")) {
body["designation"] = designationController.text.trim();
}
if (addressController.text.trim() != (current?.address ?? "")) {
body["address"] = addressController.text.trim();
}
if (profileImageBase64 != null) {
body["profilePicture"] = profileImageBase64;
}
if (body.isEmpty) {
Get.snackbar(
"Info",
"No changes found",
);
return;
}
final response = await ApiService.postDataeKyc(
EnvConfig.getProfileDetails,
body,authValue: "Bearer ${EnvConfig.token}"
);
if (response != null) {
Get.snackbar(
"Success",
"Profile updated successfully",
);
}
await GetProfileDetails();
} catch (e) {
Get.snackbar(
"Error",
e.toString(),
);
} finally {
isUpdating.value = false;
}
}