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

60 lines
1.3 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 int id;
final String name;
final List<PokemonTypeDto> types;
final PokemonSpritesDto sprites;
const PokemonDto({
required this.id,
required this.name,
required this.types,
required this.sprites,
});
factory PokemonDto.fromJson(Map<String, dynamic> json) => _$PokemonDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class PokemonTypeDto {
final int slot;
final PokemonTypeDetailDto type;
const PokemonTypeDto({
required this.slot,
required this.type,
});
factory PokemonTypeDto.fromJson(Map<String, dynamic> json) => _$PokemonTypeDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class PokemonTypeDetailDto {
final String name;
final String url;
const PokemonTypeDetailDto({
required this.name,
required this.url,
});
2024-10-16 23:18:15 +04:00
factory PokemonTypeDetailDto.fromJson(Map<String, dynamic> json) =>
_$PokemonTypeDetailDtoFromJson(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-16 23:18:15 +04:00
factory PokemonSpritesDto.fromJson(Map<String, dynamic> json) =>
_$PokemonSpritesDtoFromJson(json);
}