callConvertCurrencyApi method

Future<void> callConvertCurrencyApi(
  1. String from,
  2. String to,
  3. String amount
)

Implementation

Future<void> callConvertCurrencyApi(
    String from, String to, String amount) async {
  BuildContext context = Get.context!;
  var body = {
    "from": from, //
    "to": to,
    "amount": amount, //
  };
  try {
    await ApiClient(baseUrl: ApiConstant.posBaseUrl)
        .getConvertCurrency(
      body: body,
    )
        .then((response) async {
      ConvertCurrencyModel model = response;
      if (model.data!.price!.amount != null) {
        priceKHR.value = model.data!.price!.amount.toString() ?? "0.0";
      }

      isConvertLoading.value = true;
    }).catchError((onError) {
      isConvertLoading.value = false;
      Helper.messageDialog(context, 'tryAgain'.tr, onError.toString());
    }).catchError((onError) {
      Helper.messageDialog(context, 'tryAgain'.tr, onError.toString());
    });
  } catch (e, st) {
    print(st);
  }
}