getSupportedCurrencies function

Future<List<FiatCurrency>> getSupportedCurrencies()

Implementation

Future<List<FiatCurrency>> getSupportedCurrencies() async {
  try {
    final res = await _platform.getSupportedCurrencies();
    if (res == null) {
      throw Exception('Unable to get user currency.');
    }
    final currencies = res['currencies'] as List<dynamic>;
    return currencies
        .map<FiatCurrency>(
          (currency) => FiatCurrency.fromJson(Map<String, dynamic>.from(json.decode(json.encode(currency)))),
        )
        .toList();
  } catch (error, stackTrace) {
    Error.throwWithStackTrace(error, stackTrace);
  }
}