getGlobalData method
Get cryptocurrency global data.
Query: /global
Implementation
Future<CoinGeckoResult<GlobalCoinData?>> getGlobalData() async {
final response = await _dio.get(
'/global',
);
if (response.statusCode == 200) {
final data = Convert.toMapN<String, dynamic>(response.data['data']);
final result = data != null ? GlobalCoinData.fromJson(data) : null;
return CoinGeckoResult(result);
} else {
return CoinGeckoResult(
null,
errorCode: response.statusCode ?? null,
errorMessage: '${response.statusMessage} - ${response.data.toString()}',
isError: true,
);
}
}