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
      ? new NamedAPIResource.fromJson(json['fling_effect'])
      : null;
  if (json['attributes'] != null) {
    attributes = new List<NamedAPIResource>();
    json['attributes'].forEach((v) {
      attributes.add(new NamedAPIResource.fromJson(v));
    });
  }
  category = json['category'] != null
      ? new NamedAPIResource.fromJson(json['category'])
      : null;
  if (json['effect_entries'] != null) {
    effectEntries = new List<EffectEntries>();
    json['effect_entries'].forEach((v) {
      effectEntries.add(new EffectEntries.fromJson(v));
    });
  }
  if (json['flavor_text_entries'] != null) {
    flavorTextEntries = new List<FlavorTextEntries>();
    json['flavor_text_entries'].forEach((v) {
      flavorTextEntries.add(new FlavorTextEntries.fromJson(v));
    });
  }
  if (json['game_indices'] != null) {
    gameIndices = new List<GameIndices>();
    json['game_indices'].forEach((v) {
      gameIndices.add(new GameIndices.fromJson(v));
    });
  }
  if (json['names'] != null) {
    names = new List<Names>();
    json['names'].forEach((v) {
      names.add(new Names.fromJson(v));
    });
  }
  sprites =
      json['sprites'] != null ? new Sprites.fromJson(json['sprites']) : null;
  if (json['held_by_pokemon'] != null) {
    heldByPokemon = new List<HeldByPokemon>();
    json['held_by_pokemon'].forEach((v) {
      heldByPokemon.add(new HeldByPokemon.fromJson(v));
    });
  }
  babyTriggerFor = json['baby_trigger_for'] != null
      ? new BabyTriggerFor.fromJson(json['baby_trigger_for'])
      : null;
}