getDataById method

Future<CoinGeckoResult<NftCollectionData?>> getDataById({
  1. required String id,
})

Get all the NFT data (name, floor price, 24 hr volume....) based on the nft collection id

id sets NFT collection id

Query path: /nfts/{id}

Implementation

Future<CoinGeckoResult<NftCollectionData?>> getDataById({
  required String id,
}) async {
  final response = await _client.dio.get(
    '/nfts/$id',
  );
  if (response.statusCode == 200) {
    final map = Convert.toMapN<String, dynamic>(response.data);
    final data = map != null ? NftCollectionData.fromJson(map) : null;
    return CoinGeckoResult(data);
  } else {
    return CoinGeckoResult(
      null,
      errorMessage: response.data.toString(),
      errorCode: response.statusCode ?? null,
      isError: true,
    );
  }
}