2024-10-14 21:25:43 +04:00
|
|
|
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
|
|
|
|
part 'pokemon_dto.g.dart';
|
|
|
|
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
|
|
class PokemonDto {
|
2024-10-17 00:37:52 +04:00
|
|
|
final String? name;
|
|
|
|
final int? baseExperience;
|
|
|
|
final List<PokemonTypeDto>? types;
|
|
|
|
final List<PokemonAbilityDto>? abilities;
|
|
|
|
final PokemonSpritesDto? sprites;
|
2024-10-14 21:25:43 +04:00
|
|
|
|
|
|
|
const PokemonDto({
|
2024-10-17 00:37:52 +04:00
|
|
|
this.name,
|
|
|
|
this.baseExperience,
|
|
|
|
this.types,
|
|
|
|
this.abilities,
|
|
|
|
this.sprites,
|
2024-10-14 21:25:43 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
factory PokemonDto.fromJson(Map<String, dynamic> json) => _$PokemonDtoFromJson(json);
|
|
|
|
}
|
|
|
|
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
|
|
class PokemonTypeDto {
|
2024-10-17 00:37:52 +04:00
|
|
|
final int? slot;
|
|
|
|
final TypeDto? type;
|
2024-10-14 21:25:43 +04:00
|
|
|
|
2024-10-17 00:37:52 +04:00
|
|
|
const PokemonTypeDto({this.slot, this.type});
|
2024-10-14 21:25:43 +04:00
|
|
|
|
|
|
|
factory PokemonTypeDto.fromJson(Map<String, dynamic> json) => _$PokemonTypeDtoFromJson(json);
|
|
|
|
}
|
|
|
|
|
|
|
|
@JsonSerializable(createToJson: false)
|
2024-10-17 00:37:52 +04:00
|
|
|
class TypeDto {
|
|
|
|
final String? name;
|
|
|
|
final String? url;
|
2024-10-14 21:25:43 +04:00
|
|
|
|
2024-10-17 00:37:52 +04:00
|
|
|
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});
|
2024-10-14 21:25:43 +04:00
|
|
|
|
2024-10-17 00:37:52 +04:00
|
|
|
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);
|
2024-10-14 21:25:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
|
|
class PokemonSpritesDto {
|
|
|
|
final String front_default;
|
|
|
|
|
|
|
|
const PokemonSpritesDto({
|
|
|
|
required this.front_default,
|
|
|
|
});
|
|
|
|
|
2024-10-17 00:37:52 +04:00
|
|
|
factory PokemonSpritesDto.fromJson(Map<String, dynamic> json) => _$PokemonSpritesDtoFromJson(json);
|
|
|
|
}
|