getSearchTrending method

Future<CoinGeckoResult<SearchTrending?>> getSearchTrending()

Get trending search coins (Top-7) on CoinGecko in the last 24 hours.

Query path: /search/trending

Implementation

Future<CoinGeckoResult<SearchTrending?>> getSearchTrending() async {
  final response = await _client.dio.get(
    '/search/trending',
  );
  if (response.statusCode == 200) {
    final searchTrending = SearchTrending.fromJson(response.data);
    return CoinGeckoResult(searchTrending);
  } else {
    return CoinGeckoResult(
      null,
      errorCode: response.statusCode ?? null,
      errorMessage: '${response.statusMessage} - ${response.data.toString()}',
      isError: true,
    );
  }
}