Files
pokemon_api_dart/README.md
2023-07-05 23:26:41 +03:00

1.8 KiB

Pokemon API client for Flutter/Dart projects.

Credits to https://pokeapi.co for the API itself.

Features

  • Fully typed and documented
  • Easy fetching of linked resources
  • Swappable cache

Getting started

After installing, import and get a reference to the client.

You can use the default instance, or swap it with your own.

import 'package:pokemon_api/pokemon_api.dart';

// optionally swap the instance
PokemonAPIClient.setInstance(PokemonAPIClient());

// access the swapped (or default) instance
final api = PokemonAPIClient.instance;

Usage

You can see <examples/main.dart> for more examples.

// get the pokemon list

final pokemonList = PokemonAPIClient.getPokemonList();

// get a specific pokemon
final charmander = PokemonAPIClient.getPokemonByNameOrId('charmander');
final charmander = PokemonAPIClient.getPokemonByNameOrId('4');

// easily get linked references
final encounters = await charmander.locationAreaEncounters.get();
final locationArea = await encounters[0].locationArea.get();
final forms = await charmander.forms.map((f) => f.get()).toList();

Contributing

I am developing this package on my free time, so any support, whether code, issues, or just stars is very helpful to sustaining its life. If you are feeling incredibly generous and would like to donate just a small amount to help sustain this project, I would be very very thankful!

Buy Me a Coffee at ko-fi.com

I welcome any issues or pull requests on GitHub. If you find a bug, or would like a new feature, don't hesitate to open an appropriate issue and I will do my best to reply promptly.