scryfall_api 2.2.0
scryfall_api: ^2.2.0 copied to clipboard
A wrapper of the Scryfall API for the Dart programming language.
import 'package:scryfall_api/scryfall_api.dart';
/// Example usage of the Scryfall API wrapper.
void main() async {
// Instantiate the Scyfall API Client.
final apiClient = ScryfallApiClient();
// Retrieve the [Adventures in the Forgotten Realms](https://scryfall.com/sets/afr)
//set by its unique code (`afr`).
final afrSet = await apiClient.getSetByCode('afr');
// Print information about the set.
print('Name of set: ${afrSet.name}');
print('URI of set icon: ${afrSet.iconSvgUri}');
print('Number of cards in set: ${afrSet.printedSize}');
// Retrieve the 'Black Lotus' card by its name.
final blackLotus = await apiClient.getCardByName('black lotus');
// Print information about the card.
print('Name of card: ${blackLotus.name}');
print('Mana cost of card: ${blackLotus.manaCost}');
print('Oracle text of card: ${blackLotus.oracleText}');
// Get all spell types.
final spellTypes = await apiClient.getSpellTypes();
// Print the spell types.
print('Number of spell types: ${spellTypes.length}');
print('Spell types: ${spellTypes.data}');
// Close API Client when it's not used anymore.
apiClient.close();
}