pokedex 0.3.0 copy "pokedex: ^0.3.0" to clipboard
pokedex: ^0.3.0 copied to clipboard

A Dart wrapper for PokeAPI that provides everything Pokémon-related.

pokedex #

Pub style: lint License: MIT

A Dart wrapper for PokeAPI.

pokedex is heavily inspired by chulwoo-park's pokeapi_dart.

Table of Contents

Installation #

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.

Usage #

import 'package:pokedex/pokedex.dart';
final dex = Pokedex();

Simple requests #

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);
}

Endpoints #

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.

Berries #

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);
})

Contests #

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);
})

Encounters #

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);
})

Evolution #

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);
})

Games #

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);
})

Items #

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);
})

Locations #

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);
})

Machines #

Use machines to return data about specific machine.

Pokedex().machines.get(id: 2).then((response) {
  print(response);
})

Moves #

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);
})

Pokemon #

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);
})

Utility #

Use languages to return data about specific pokemon language.

Pokedex().languages.get(name: 'ja').then((response) {
  print(response);
})

Root Endpoints #

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. Default 0
  • limit is how many items you want to list. Default 20

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:

getPage

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:

getAll

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:

getByUrl

12
likes
110
pub points
45%
popularity

Publisher

unverified uploader

A Dart wrapper for PokeAPI that provides everything Pokémon-related.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

freezed_annotation, http, json_annotation

More

Packages that depend on pokedex