removeCard method

dynamic removeCard(
  1. BuildContext context,
  2. String cardId
)

Implementation

removeCard(BuildContext context, String cardId) async {
  try {
    isLoading(true);
    var request = {
      'token': Storage.getValue(Constants.token),
      'api_key': Constants.apiKey,
      'sub_client_api_key': Storage.getValue(Constants.subClientApiKey),
      'card_id': cardId
    };

    var response = await DioClient().request(context: context,
        api: '/delete-funding-source', method: Method.POST, params: request);

    DeleteFundSourceResponse deleteFundSourceResponse =
        DeleteFundSourceResponse.fromJson(response);
    if (deleteFundSourceResponse.status == Strings.success) {
      allCards.clear();
      allBankAccounts.clear();
      Utils.showSnackbar(context, Strings.success,
          deleteFundSourceResponse.message!, AppColors.green);
    } else {
      return Utils.showSnackbar(
          context, Strings.error, response['message'], AppColors.red);
    }
  } finally {
    isLoading(false);
    fetchfundingSources(context);
  }
  update();
}