editShopDetails method
Implementation
void editShopDetails(BuildContext context) async {
FocusScope.of(context).requestFocus(FocusNode());
if (formKey.currentState!.validate()) {
FocusScope.of(context).unfocus();
try{
isLoading.value = true;
var request = {
'merchant_id': Storage.getValue(Constants.merchantID),
'api_key': await Constants.apiKey(),
'name': storeName.text.toString(),
'description': storeDescription.text.toString(),
'category': storeCategory,
'street_address': streetAddressController.text.toString(),
'zip': zipCodeController.text.toString(),
'country': country.text.toString(),
'state': state.text.toString(),
'city': city.text.toString(),
};
var response = await DioClient().request(context: context,
api: '/merchant/update', method: Method.POST, params: request);
GetSingleMerchantResponse getSingleMerchantResponse =
GetSingleMerchantResponse.fromJson(response);
if (getSingleMerchantResponse.status == Strings.success) {
Utils.navigationReplace(
context,
SuccessfulMgs(
successTitle: Strings.storeUpdatedSuccessfully,
successMessage: DateFormat.jm()
.format(DateTime.parse(DateTime.now().toString()).toLocal()),
));
shopDetailController.fetchShopDetails(context);
} else {
return Utils.showSnackbar(
context, Strings.error, response['message'].toString().toTitleCase(), AppColors.red);
}
}catch(e){
return Utils.showSnackbar(
context, Strings.error, e.toString(), AppColors.red);
} finally {
isLoading(false);
}
update();
}
}