getAllSets method

Future<PaginableList<MtgSet>> getAllSets()

GET /sets

Returns a PaginableList of all MtgSets on Scryfall.

Implementation

Future<PaginableList<MtgSet>> getAllSets() async {
  final url = Uri.https(_baseUrl, '/sets');
  final response = await _httpClient.get(url);

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

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

  return PaginableList<MtgSet>.fromJson(
    json,
    (set) => MtgSet.fromJson(set as Map<String, dynamic>),
  );
}