A Dart wrapper for PokeAPI.
pokedex is heavily inspired by chulwoo-park's pokeapi_dart.
Table of Contents
Add this to your package's pubspec.yaml file:
dependencies:
pokedex: ^0.3.0
Then run dart pub get
or flutter pub get
if you are using Flutter.
Now in your Dart code, you can use:
import 'package:pokedex/pokedex.dart';
Check out the documentation for this package and PokeAPI for more information.
import 'package:pokedex/pokedex.dart';
final dex = Pokedex();
❕ Some pokemon has multiple forms: If you want to get the data for a specific pokemon species, it is recommended to use pokemonSpecies endpoint instead of pokemon endpoints, as shown below.
See also issue #635
import 'package:pokeapi_dart/pokeapi_dart.dart';
Future<void> main() async {
final pokedex = Pokedex();
// get Aegislash species information with async function
final aegislashSpecies = pokedex.pokemonSpecies.get(name: 'aegislash');
print(aegislashSpecies);
// get pokemon by name
final aegislashBlade = await pokedex.pokemon.get(name: 'aegislash-blade');
final aegislashShield = await pokedex.pokemon.get(id: 'aegislash-shield');
// get pokemon by id
aegislashBlade = await pokedex.pokemon.get(id: 10026);
aegislashShield = await pokedex.pokemon.get(id: 681);
}
The get method can use id
or name
as a parameter according to each endpoint type.
Refer to the pokeapi v2 docs to find out more about how the data is structured.
Use berries to return data about a specific berry.
Pokedex().berries.get(name: 'cheri').then((response) {
print(response);
});
Use berryFirmnesses to return data about the firmness of a specific berry.
Pokedex().berryFirmnesses.get(name: 'very-soft').then((response) {
print(response);
});
Use berryFlavors to return data about the flavor of a specific berry.
Pokedex().berryFlavors.get(name: 'spicy').then((response) {
print(response);
})
Use contestTypes to return data about the effects of moves when used in contests.
Pokedex().contestTypes.get(name: 'cool').then((response) {
print(response);
})
Use contestEffects to return data about the effects of moves when used in contests.
Pokedex().contestEffects.get(id: 1).then((response) {
print(response);
})
Use superContestEffects to return data about the effects of moves when used in super contests.
Pokedex().superContestEffects.get(id: 1).then((response) {
print(response);
})
Use encounterMethods to return data about the conditions in which a trainer may encounter a pokemon in the wild.
Pokedex().encounterMethods.get(name: 'walk').then((response) {
print(response);
})
Use encounterConditions to return data that affects which pokemon might appear in the wild.
Pokedex().encounterConditions.get(name: 'swarm').then((response) {
print(response);
})
Use encounterConditionValues to return data the various states that an encounter condition can have.
Pokedex().encounterConditionValues.get(name: 'swarm-yes').then((response) {
print(response);
})
Use evolutionChains to return data evolution chains.
Pokedex().evolutionChains.get(id: 1).then((response) {
print(response);
})
Use evolutionTriggers to return data about triggers which cause pokemon to evolve.
Pokedex().evolutionTriggers.get(name: 'level-up').then((response) {
print(response);
})
Use generations to return data about the different generations of pokemon games.
Pokedex().generations.get(name: 'generation-i').then((response) {
print(response);
})
Use pokedexes to return data about specific types of pokedexes.
Pokedex().pokedexes.get(name: 'kanto').then((response) {
print(response);
})
Use versions to return data about specific versions of pokemon games.
Pokedex().versions.get(name: 'red').then((response) {
print(response);
})
Use versionGroups to return data about specific version groups of pokemon games.
Pokedex().versionGroups.get(name: 'red-blue').then((response) {
print(response);
})
Use items to return data about specific items.
Pokedex().items.get(name: 'master-ball').then((response) {
print(response);
})
Use itemAttributes to return data about specific item attribute.
Pokedex().itemAttributes.get(name: 'countable').then((response) {
print(response);
})
Use itemCategories to return data about specific item category.
Pokedex().itemCategories.get(name: 'stat-boosts').then((response) {
print(response);
})
Use itemFlingEffects to return data about specific item fling effect.
Pokedex().itemFlingEffects.get(name: 'badly-poison').then((response) {
print(response);
})
Use itemPockets to return data about specific pockets in a players bag.
Pokedex().itemPockets.get(name: 'misc').then((response) {
print(response);
})
Use locations to return data about specific pokemon location.
Pokedex().locations.get(name: 'sinnoh').then((response) {
print(response);
})
Use locationAreas to return data about specific pokemon location area.
Pokedex().locationAreas.get(name: 'canalave-city-area').then((response) {
print(response);
})
Use palParkAreas to return data about specific pokemon pal park area.
Pokedex().palParkAreas.get(name: 'forest').then((response) {
print(response);
})
Use regions to return data about specific pokemon region.
Pokedex().regions.get(name: 'kanto').then((response) {
print(response);
})
Use machines to return data about specific machine.
Pokedex().machines.get(id: 2).then((response) {
print(response);
})
Use moves to return data about specific pokemon move.
Pokedex().moves.get(name: 'pound').then((response) {
print(response);
})
Use moveAilments to return data about specific pokemon move ailment.
Pokedex().moveAilments.get(name: 'paralysis').then((response) {
print(response);
})
Use moveBattleStyles to return data about specific pokemon move battle style.
Pokedex().moveBattleStyles.get(name: 'attack').then((response) {
print(response);
})
Use moveCategories to return data about specific pokemon move category.
Pokedex().moveCategories.get(name: 'ailment').then((response) {
print(response);
})
Use moveDamageClasses to return data about specific pokemon damage class.
Pokedex().moveDamageClasses.get(name: 'status').then((response) {
print(response);
})
Use moveLearnMethods to return data about specific pokemon learn method.
Pokedex().moveLearnMethods.get(name: 'level-up').then((response) {
print(response);
})
Use moveTargets to return data about specific pokemon move target.
Pokedex().moveTargets.get(name: 'specific-move').then((response) {
print(response);
})
Use abilities to return data about specific pokemon ability.
Pokedex().abilities.get(name: 'stench').then((response) {
print(response);
})
Use characteristics to return data about specific pokemon characteristic.
Pokedex().characteristics.get(id: 1).then((response) {
print(response);
})
Use eggGroups to return data about specific pokemon egg group.
Pokedex().eggGroups.get(name: 'monster').then((response) {
print(response);
})
Use genders to return data about specific pokemon gender.
Pokedex().genders.get(name: 'female').then((response) {
print(response);
})
Use growthRates to return data about specific pokemon growth rate.
Pokedex().growthRates(name: 'slow').then((response) {
print(response);
})
Use natures to return data about specific pokemon nature.
Pokedex().natures.get(name: 'bold').then((response) {
print(response);
})
Use pokeathlonStats to return data about specific pokeathon stat.
Pokedex().pokeathlonStats.get(name: 'speed').then((response) {
print(response);
})
Use pokemon to return data about specific pokemon.
Pokedex().pokemon.get(name: 'clefairy').then((response) {
print(response);
})
Use pokemonColors to return data about specific pokemon color.
Pokedex().pokemonColors.get(name: 'black').then((response) {
print(response);
})
Use pokemonForms to return data about specific pokemon form.
Pokedex().pokemonForms.get(name: 'arceus-bug').then((response) {
print(response);
})
Use pokemonHabitats to return data about specific pokemon habitat.
Pokedex().pokemonHabitats.get(name: 'cave').then((response) {
print(response);
})
Use pokemonShapes to return data about specific pokemon shape.
Pokedex().pokemonShapes.get(name: 'ball').then((response) {
print(response);
})
Use pokemonSpecies to return data about specific pokemon species.
Pokedex().pokemonSpecies.get(name: 'wormadam').then((response) {
print(response);
})
Use stats to return data about specific pokemon stat.
Pokedex().stats.get(name: 'attack').then((response) {
print(response);
})
Use types to return data about specific pokemon type.
Pokedex().types.get(name: 'ground').then((response) {
print(response);
})
Use languages to return data about specific pokemon language.
Pokedex().languages.get(name: 'ja').then((response) {
print(response);
})
Each endpoint provides a getPage
method to get paged items contained by that endpoint.
It can configure offset and limit.
offset
is where to start. The first item that you will get. Default0
limit
is how many items you want to list. Default20
This call will get the list of Pokémon between ID 35 and ID 44
Pokedex().pokemon.getPage(offset: 34, limit 10).then((response) {
print(response);
})
This is what you will get:
Or you can get all items with getAll
.
This call will get all items within the pokemon endpoint.
Pokedex().pokemon.getAll().then((response) {
print(response);
})
This is what you will get:
Each endpoint also provides a getByUrl
method to fetch a specific item with a provided url.
This call will get the Pokémon with id 274.
Pokedex().pokemon.getByUrl('https://pokeapi.co/api/v2/pokemon/274/').then((response) {
print(response);
})
This is what you will get: