fetchSingleAddress method

void fetchSingleAddress(
  1. BuildContext context,
  2. String addressId
)

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();
}