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

92 lines
2.2 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)
2024-10-29 14:54:56 +04:00
class PokemonDto {
final List<PokemonDataDto>? results;
2024-10-29 14:36:44 +04:00
final int? count;
final String? next;
final String? previous;
2024-10-29 14:54:56 +04:00
const PokemonDto({
this.results,
2024-10-29 14:36:44 +04:00
this.count,
this.next,
this.previous,
2024-10-14 21:25:43 +04:00
});
2024-10-29 14:36:44 +04:00
factory PokemonDto.fromJson(Map<String, dynamic> json) => _$PokemonDtoFromJson(json);
2024-10-14 21:25:43 +04:00
}
@JsonSerializable(createToJson: false)
2024-10-29 14:54:56 +04:00
class PokemonDataDto {
final String? name;
2024-10-29 14:54:56 +04:00
final String? url;
final String? imageUrl;
2024-11-18 15:05:17 +04:00
final int? height;
final int? weight;
final List<AbilityDto>? abilities;
// final PokemonAttributesDataDto? attributes;
2024-10-29 14:54:56 +04:00
const PokemonDataDto({
2024-10-18 21:36:44 +04:00
this.name,
2024-10-29 14:54:56 +04:00
this.url,
this.imageUrl,
2024-11-16 12:59:11 +04:00
this.height,
this.weight,
this.abilities,
// this.attributes,
2024-11-16 12:59:11 +04:00
});
2024-11-18 13:20:53 +04:00
factory PokemonDataDto.fromJson(Map<String, dynamic> json) => _$PokemonDataDtoFromJson(json);
2024-11-16 12:59:11 +04:00
}
// @JsonSerializable(createToJson: false)
// class PokemonAttributesDataDto {
// final String? imageUrl;
// final int? height;
// final int? weight;
// final List<AbilityDto>? abilities;
// final PokemonSpritesDto? sprites;
//
// const PokemonAttributesDataDto({
// this.imageUrl,
// this.height,
// this.weight,
// this.abilities,
// this.sprites,
// });
//
// factory PokemonAttributesDataDto.fromJson(Map<String, dynamic> json) => _$PokemonAttributesDataDtoFromJson(json);
// }
2024-11-16 12:59:11 +04:00
@JsonSerializable(createToJson: false)
class AbilityDto {
final AbilityDetailDto? ability;
const AbilityDto({this.ability});
factory AbilityDto.fromJson(Map<String, dynamic> json) => _$AbilityDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class AbilityDetailDto {
final String? name;
const AbilityDetailDto({this.name});
factory AbilityDetailDto.fromJson(Map<String, dynamic> json) => _$AbilityDetailDtoFromJson(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);
// }