exchangeRate method

Future<double> exchangeRate(
  1. String code, {
  2. DateTime? date,
})

Get currency exchange rate.

Implementation

Future<double> exchangeRate(String code, {DateTime? date}) async {
  if (_exchangeRate.containsKey(code)) {
    return Future.value(_exchangeRate[code]);
  }
  final response = await dio
      .get('/cube/exchangeRate/$code', queryParameters: {'date': date});
  _exchangeRate[code] = double.parse(response.data);
  return response.data ?? 1;
}