getExchangeRate method

ExchangeRate? getExchangeRate({
  1. required Currency from,
  2. required Currency to,
})

Returns the exchange rate which matches with from and to currencies. If this does not exist in this list, it returns null.

Implementation

ExchangeRate? getExchangeRate({
  required Currency from,
  required Currency to,
}) {
  try {
    return firstWhere((e) => e.from == from && e.to == to);
    // ignore: avoid_catches_without_on_clauses
  } catch (e) {
    return null;
  }
}