rateViaBTC method

num rateViaBTC(
  1. String source,
  2. String target
)

Converts source → BTC → target.

Implementation

num rateViaBTC(String source, String target) {
  ExchangeRate sourceRate = data[source], btcRate = data['BTC'];
  if (sourceRate == null || btcRate == null) return 0;
  ExchangeRateTo toBtc = sourceRate.to['BTC'], toTarget = btcRate.to[target];
  if (toBtc == null || toTarget == null) return 0;
  return (toBtc.value ?? 0) * (toTarget.value ?? 0);
}