searchFor method
Search for coins, categories, and markets listed on CoinGecko ordered by largest Market Cap first.
query
: The search query string.
Query path: /search
Implementation
Future<CoinGeckoResult<SearchResults?>> searchFor({
required String query,
}) async {
final response = await _client.dio.get(
'/search',
queryParameters: {
'query': query,
},
);
if (response.statusCode == 200) {
final searchResults = SearchResults.fromJson(response.data);
return CoinGeckoResult(searchResults);
} else {
return CoinGeckoResult(
null,
errorCode: response.statusCode ?? null,
errorMessage: '${response.statusMessage} - ${response.data.toString()}',
isError: true,
);
}
}