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

57 lines
1.3 KiB
Dart

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,
});
factory PokemonTypeDetailDto.fromJson(Map<String, dynamic> json) => _$PokemonTypeDetailDtoFromJson(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);
}