Item.fromJson constructor

Item.fromJson(
  1. Map<String, dynamic> json
)

Implementation

Item.fromJson(Map<String, dynamic> json) {
  id = json['id'];
  name = json['name'];
  cost = json['cost'];
  flingPower = json['fling_power'];
  flingEffect = json['fling_effect'] != null
      ?  NamedAPIResource.fromJson(json['fling_effect'])
      : null;
  if (json['attributes'] != null) {
    attributes =  <NamedAPIResource>[];
    json['attributes'].forEach((v) {
      attributes!.add( NamedAPIResource.fromJson(v));
    });
  }
  category = json['category'] != null
      ?  NamedAPIResource.fromJson(json['category'])
      : null;
  if (json['effect_entries'] != null) {
    effectEntries =  <EffectEntries>[];
    json['effect_entries'].forEach((v) {
      effectEntries!.add( EffectEntries.fromJson(v));
    });
  }
  if (json['flavor_text_entries'] != null) {
    flavorTextEntries =  <FlavorTextEntries>[];
    json['flavor_text_entries'].forEach((v) {
      flavorTextEntries!.add( FlavorTextEntries.fromJson(v));
    });
  }
  if (json['game_indices'] != null) {
    gameIndices =  <GameIndices>[];
    json['game_indices'].forEach((v) {
      gameIndices!.add( GameIndices.fromJson(v));
    });
  }
  if (json['names'] != null) {
    names =  <Names>[];
    json['names'].forEach((v) {
      names!.add( Names.fromJson(v));
    });
  }
  sprites =
      json['sprites'] != null ?  Sprites.fromJson(json['sprites']) : null;
  if (json['held_by_pokemon'] != null) {
    heldByPokemon =  <HeldByPokemon>[];
    json['held_by_pokemon'].forEach((v) {
      heldByPokemon!.add( HeldByPokemon.fromJson(v));
    });
  }
  babyTriggerFor = json['baby_trigger_for'] != null
      ?  BabyTriggerFor.fromJson(json['baby_trigger_for'])
      : null;
}