listCoins method

Future<CoinGeckoResult<List<CoinShort>>> listCoins({
  1. bool includePlatforms = false,
})

List all supported coins id, name and symbol.

includePlatforms sets whether platform information should be included. Default is false.

Query: /coins/list

Implementation

Future<CoinGeckoResult<List<CoinShort>>> listCoins({
  bool includePlatforms = false,
}) async {
  final response = await _dio.get(
    '/coins/list',
    queryParameters: {
      'include_platform': includePlatforms,
    },
  );
  if (response.statusCode == 200) {
    List<CoinShort> coinList = [];
    for (dynamic coinJson in response.data) {
      coinList.add(CoinShort.fromJson(coinJson));
    }
    return CoinGeckoResult(coinList);
  } else {
    return CoinGeckoResult(
      [],
      errorMessage: response.data.toString(),
      errorCode: response.statusCode ?? 0,
      isError: true,
    );
  }
}