fetchAddress method
Implementation
void fetchAddress(BuildContext context) async {
try {
isLoading(true);
var request = {
'merchant_id': Storage.getValue(Constants.merchantID),
'api_key': await Constants.apiKey(),
'customer_id': Storage.getValue(Constants.customerID)
};
var response = await DioClient()
.request(context: context,api: '/customer/shipping/get', method: Method.POST, params: request);
AllShippingAddressResponse getAddressResponse = AllShippingAddressResponse.fromJson(response);
if (getAddressResponse.status == Strings.success) {
addresses = getAddressResponse.data!.obs;
} else {
return Utils.showSnackbar(
context, Strings.error, response['message'].toString().toTitleCase(), AppColors.red);
}
}catch(e){
return Utils.showSnackbar(
context, Strings.error, e.toString().toTitleCase(), AppColors.red);
} finally {
isLoading(false);
}
update();
}