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

73 lines
1.7 KiB
Dart
Raw Normal View History

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 {
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({
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 {
final int? slot;
final TypeDto? type;
2024-10-14 21:25:43 +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)
class TypeDto {
final String? name;
final String? url;
2024-10-14 21:25:43 +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
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,
});
factory PokemonSpritesDto.fromJson(Map<String, dynamic> json) => _$PokemonSpritesDtoFromJson(json);
}