Pokemon.fromJson constructor
Pokemon.fromJson(
- Map<String, dynamic> json
)
Implementation
Pokemon.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
baseExperience = json['base_experience'];
height = json['height'];
isDefault = json['is_default'];
order = json['order'];
weight = json['weight'];
if (json['abilities'] != null) {
abilities = <Abilities>[];
json['abilities'].forEach((v) {
abilities!.add( Abilities.fromJson(v));
});
}
if (json['forms'] != null) {
forms = <NamedAPIResource>[];
json['forms'].forEach((v) {
forms!.add( NamedAPIResource.fromJson(v));
});
}
if (json['game_indices'] != null) {
gameIndices = <GameIndices>[];
json['game_indices'].forEach((v) {
gameIndices!.add( GameIndices.fromJson(v));
});
}
if (json['held_items'] != null) {
heldItems = <HeldItems>[];
json['held_items'].forEach((v) {
heldItems!.add( HeldItems.fromJson(v));
});
}
if (json['moves'] != null) {
moves = <Moves>[];
json['moves'].forEach((v) {
moves!.add( Moves.fromJson(v));
});
}
species = json['species'] != null
? NamedAPIResource.fromJson(json['species'])
: null;
sprites =
json['sprites'] != null ? Sprites.fromJson(json['sprites']) : null;
if (json['stats'] != null) {
stats = <Stats>[];
json['stats'].forEach((v) {
stats!.add( Stats.fromJson(v));
});
}
if (json['types'] != null) {
types = <Types>[];
json['types'].forEach((v) {
types!.add( Types.fromJson(v));
});
}
}