editProfile method
Implementation
void editProfile(BuildContext context)async {
FocusScope.of(context).requestFocus(FocusNode());
if (formKey.currentState!.validate()) {
FocusScope.of(context).unfocus();
try {
isLoading(true);
var request = {
'token': Storage.getValue(Constants.token),
'api_key': Constants.apiKey,
'sub_client_api_key': Storage.getValue(Constants.subClientApiKey),
'first_name' : firstNameController.text.toString(),
'last_name' : lastNameController.text.toString(),
'phone_number' : mobilenumberController.text.toString(),
'date_of_birth' : dobController.text.toString(),
};
var response = await DioClient()
.request(context: context,api: '/update-profile', method: Method.POST, params: request);
UpdateProfileResponse updateProfileResponse = UpdateProfileResponse.fromJson(response);
if (updateProfileResponse.status == Strings.success) {
Utils.navigationReplace(context,Successful(
successTitle: Strings.profileUpdatedSuccessfully,
successMessage: DateFormat.jm().format(DateTime.parse(DateTime.now().toString()).toLocal()),));
Utils.showSnackbar(context,Strings.success, updateProfileResponse.message!, AppColors.green);
profileController.fetchUserProfile(context);
}else{
return Utils.showSnackbar(context, Strings.error,response['message'].toString().toTitleCase(), AppColors.red);
}
} finally {
isLoading(false);
}
update();
}
}