getCardById method

Future<MtgCard> getCardById(
  1. String id
)

GET /cards/:id

Returns a single card with the given id on Scryfall.

Implementation

Future<MtgCard> getCardById(String id) async {
  final url = Uri.https(_baseUrl, '/cards/$id');
  final response = await _httpClient.get(url);

  final json = jsonDecode(response.body) as Map<String, dynamic>;

  if (response.statusCode != 200) {
    throw ScryfallException.fromJson(json);
  }

  return MtgCard.fromJson(json);
}