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

64 lines
1.5 KiB
Dart

import 'package:json_annotation/json_annotation.dart';
part 'pokemon_dto.g.dart';
@JsonSerializable(createToJson: false)
class PokemonDto {
final List<PokemonDataDto>? data;
final MetaDto? meta;
const PokemonDto({
this.data,
this.meta,
});
factory PokemonDto.fromJson(Map<String, dynamic> json) => _$PokemonDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class PokemonDataDto {
final String? id;
final String? type;
final PokemonAttributesDataDto? attributes;
const PokemonDataDto({this.id, this.type, this.attributes});
factory PokemonDataDto.fromJson(Map<String, dynamic> json) => _$PokemonDataDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class PokemonAttributesDataDto {
final String? name;
final String? height;
final String? weight;
final String? image;
const PokemonAttributesDataDto({
this.name,
this.height,
this.weight,
this.image,
});
factory PokemonAttributesDataDto.fromJson(Map<String, dynamic> json) => _$PokemonAttributesDataDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class MetaDto {
final PaginationDto? pagination;
const MetaDto({this.pagination});
factory MetaDto.fromJson(Map<String, dynamic> json) => _$MetaDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class PaginationDto {
final int? current;
final int? next;
final int? last;
const PaginationDto({this.current, this.next, this.last});
factory PaginationDto.fromJson(Map<String, dynamic> json) => _$PaginationDtoFromJson(json);
}