PMU_Repo/lib/data/dtos/characters_dto.dart

47 lines
1.2 KiB
Dart
Raw Normal View History

2024-12-20 18:07:20 +04:00
import 'package:json_annotation/json_annotation.dart';
part 'characters_dto.g.dart';
@JsonSerializable(createToJson: false)
class CharactersDto {
final List<CharactersDataDto>? data;
2024-12-20 20:30:13 +04:00
final MetaDto meta;
2024-12-20 18:07:20 +04:00
2024-12-20 20:30:13 +04:00
const CharactersDto ({this.data, required this.meta});
2024-12-20 18:07:20 +04:00
factory CharactersDto.fromJson(Map<String, dynamic> json) => _$CharactersDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class CharactersDataDto {
2024-12-20 20:30:13 +04:00
final int id;
final String fullName;
final String title;
final String family;
final String imageUrl;
2024-12-20 18:07:20 +04:00
const CharactersDataDto(this.id, this.fullName, this.title, this.family, this.imageUrl);
factory CharactersDataDto.fromJson(Map<String, dynamic> json) => _$CharactersDataDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class MetaDto {
2024-12-20 20:30:13 +04:00
final PaginationDto pagination;
2024-12-20 18:07:20 +04:00
2024-12-20 20:30:13 +04:00
const MetaDto({required this.pagination});
2024-12-20 18:07:20 +04:00
factory MetaDto.fromJson(Map<String, dynamic> json) =>
_$MetaDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class PaginationDto {
2024-12-20 20:30:13 +04:00
final int current;
final int next;
final int last;
2024-12-20 18:07:20 +04:00
2024-12-20 20:30:13 +04:00
const PaginationDto({required this.current, required this.next, required this.last});
2024-12-20 18:07:20 +04:00
factory PaginationDto.fromJson(Map<String, dynamic> json) =>
_$PaginationDtoFromJson(json);
}