PIbd-33_Dyakonov_R_R_PMD/lib/data/dtos/characters_dto.dart

58 lines
1.5 KiB
Dart
Raw Normal View History

2024-09-15 21:41:47 +04:00
import 'package:json_annotation/json_annotation.dart';
part 'characters_dto.g.dart';
2024-09-25 14:35:14 +04:00
// dart run build_runner build --delete-conflicting-outputs
2024-09-17 00:03:15 +04:00
@JsonSerializable(createToJson: false)
class CharactersDto {
final List<CharacterDataDto>? data;
2024-09-25 14:35:14 +04:00
final MetaDto? meta;
2024-09-17 00:03:15 +04:00
2024-09-25 14:35:14 +04:00
const CharactersDto({this.data, this.meta});
2024-09-17 00:03:15 +04:00
2024-10-02 14:02:45 +04:00
factory CharactersDto.fromJson(Map<String, dynamic> json) => _$CharactersDtoFromJson(json);
2024-09-25 14:35:14 +04:00
}
@JsonSerializable(createToJson: false)
class MetaDto {
final PaginationDto? pagination;
const MetaDto({this.pagination});
2024-10-02 14:02:45 +04:00
factory MetaDto.fromJson(Map<String, dynamic> json) => _$MetaDtoFromJson(json);
2024-09-25 14:35:14 +04:00
}
@JsonSerializable(createToJson: false)
class PaginationDto {
final int? current;
final int? next;
final int? last;
const PaginationDto({this.current, this.last, this.next});
2024-10-02 14:02:45 +04:00
factory PaginationDto.fromJson(Map<String, dynamic> json) => _$PaginationDtoFromJson(json);
2024-09-17 00:03:15 +04:00
}
2024-09-15 21:41:47 +04:00
@JsonSerializable(createToJson: false)
class CharacterDataDto {
2024-09-17 00:03:15 +04:00
final String? id;
final CharacterAttributesDataDto? attributes;
2024-09-15 21:41:47 +04:00
2024-09-17 00:03:15 +04:00
const CharacterDataDto(this.id, this.attributes);
2024-09-15 21:41:47 +04:00
2024-10-02 14:02:45 +04:00
factory CharacterDataDto.fromJson(Map<String, dynamic> json) => _$CharacterDataDtoFromJson(json);
2024-09-15 21:41:47 +04:00
}
2024-09-17 00:03:15 +04:00
@JsonSerializable(createToJson: false)
class CharacterAttributesDataDto {
final String? name;
final String? image;
final String? species;
CharacterAttributesDataDto(this.name, this.image, this.species);
2024-09-25 14:35:14 +04:00
factory CharacterAttributesDataDto.fromJson(Map<String, dynamic> json) =>
_$CharacterAttributesDataDtoFromJson(json);
}