PIbd-32_Chubykina_P.P._mobilki/lib/data/dtos/pokemon_dto.dart

73 lines
1.7 KiB
Dart

import 'package:json_annotation/json_annotation.dart';
part 'pokemon_dto.g.dart';
@JsonSerializable(createToJson: false)
class PokemonDto {
final String? name;
final int? baseExperience;
final List<PokemonTypeDto>? types;
final List<PokemonAbilityDto>? abilities;
final PokemonSpritesDto? sprites;
const PokemonDto({
this.name,
this.baseExperience,
this.types,
this.abilities,
this.sprites,
});
factory PokemonDto.fromJson(Map<String, dynamic> json) => _$PokemonDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class PokemonTypeDto {
final int? slot;
final TypeDto? type;
const PokemonTypeDto({this.slot, this.type});
factory PokemonTypeDto.fromJson(Map<String, dynamic> json) => _$PokemonTypeDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class TypeDto {
final String? name;
final String? url;
const TypeDto({this.name, this.url});
factory TypeDto.fromJson(Map<String, dynamic> json) => _$TypeDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class PokemonAbilityDto {
final int? slot;
final AbilityDto? ability;
const PokemonAbilityDto({this.slot, this.ability});
factory PokemonAbilityDto.fromJson(Map<String, dynamic> json) => _$PokemonAbilityDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class AbilityDto {
final String? name;
final String? url;
const AbilityDto({this.name, this.url});
factory AbilityDto.fromJson(Map<String, dynamic> json) => _$AbilityDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class PokemonSpritesDto {
final String front_default;
const PokemonSpritesDto({
required this.front_default,
});
factory PokemonSpritesDto.fromJson(Map<String, dynamic> json) => _$PokemonSpritesDtoFromJson(json);
}