pokemon_tcg 1.0.0 copy "pokemon_tcg: ^1.0.0" to clipboard
pokemon_tcg: ^1.0.0 copied to clipboard

A Dart SDK for the Pokemon TCG Developers API. An API key is required to use.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:pokemon_tcg/pokemon_tcg.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final api = PokemonTcgApi(apiKey: 'your_api_key_here');
  late final paginatedCardsAll = PaginatedPokemonCards([], api);
  late final paginatedCardsSwsh5 = PaginatedPokemonCards([], api);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: Column(
          children: [
            ElevatedButton(
              child: Text('Get cards'),
              onPressed: () async {
                await paginatedCardsAll.loadMore(page: 1);
                print(paginatedCardsAll.cards);
              },
            ),
            ElevatedButton(
              child: Text('Get cards for set'),
              onPressed: () async {
                await paginatedCardsAll.loadMoreForSet('swsh5');
                print(paginatedCardsAll.cards);
              },
            ),
            ElevatedButton(
              child: Text('Get card'),
              onPressed: () async {
                final card = await api.getCard('xy7-54');
                print(card.tcgPlayer);
              },
            ),
            ElevatedButton(
              child: Text('Get set'),
              onPressed: () async {
                final set = await api.getSet('swsh5');
                print(set.id);
              },
            ),
            ElevatedButton(
              child: Text('Get sets'),
              onPressed: () async {
                final sets = await api.getSets();
                print(sets.length);
              },
            ),
            ElevatedButton(
              child: Text('Get types'),
              onPressed: () async {
                final types = await api.getTypes();
                types.forEach((element) {
                  print(element.type);
                });
              },
            ),
            ElevatedButton(
              child: Text('Get subtypes'),
              onPressed: () async {
                final types = await api.getSubtypes();
                types.forEach((element) {
                  print(element.type);
                });
              },
            ),
            ElevatedButton(
              child: Text('Get supertypes'),
              onPressed: () async {
                final types = await api.getSupertypes();
                types.forEach((element) {
                  print(element.type);
                });
              },
            ),
            ElevatedButton(
              child: Text('Get rarities'),
              onPressed: () async {
                final types = await api.getRarities();
                types.forEach((element) {
                  print(element.type);
                });
              },
            ),
          ],
        ),
      ),
    );
  }
}
8
likes
150
pub points
51%
popularity

Publisher

verified publishergroovinchip.dev

A Dart SDK for the Pokemon TCG Developers API. An API key is required to use.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on pokemon_tcg