cryptoToDollars static method

Future<double> cryptoToDollars(
  1. String slug,
  2. double assetVal, {
  3. bool useCache = true,
})

Convert crypto asset value to dollars

slug is the slug of the crypto asset, e.g bitcoin, etherum, etc. assetVal is the crypto asset value.

Returns the converted value in dollars.

Implementation

static Future<double> cryptoToDollars(String slug, double assetVal,
    {bool useCache = true}) async {
  if (_xRateMap.containsKey(slug)) {
    return _xRateMap[slug]! * assetVal;
  } else {
    AssetMetricsResponse response = await getMetrics(slug);
    return response.assetMetric.marketData.priceUsd * assetVal;
  }
}