fetchSingleAddress method
Implementation
void fetchSingleAddress(BuildContext context, String addressId) async {
try {
isLoading(true);
var request = {
'token': Storage.getValue(Constants.token),
'api_key': Constants.apiKey,
'sub_client_api_key': Storage.getValue(Constants.subClientApiKey),
};
var response = await DioClient().request(context: context,
api: '/address/$addressId', method: Method.POST, params: request);
GetSingleAddressResponse getSingleAddressResponse =
GetSingleAddressResponse.fromJson(response);
if (getSingleAddressResponse.status == Strings.success) {
Utils.showSnackbar(context, Strings.success,
getSingleAddressResponse.message!, AppColors.green);
} else {
return Utils.showSnackbar(
context, Strings.error, response['message'].toString().toTitleCase(), AppColors.red);
}
} finally {
isLoading(false);
}
update();
}