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

59 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)
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;
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,
});
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 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);
}