62 lines
1.5 KiB
Dart
62 lines
1.5 KiB
Dart
|
import 'package:json_annotation/json_annotation.dart';
|
||
|
|
||
|
part 'characters_dto.g.dart';
|
||
|
|
||
|
@JsonSerializable(createToJson: false)
|
||
|
class CharactersDto {
|
||
|
final List<CharacterDto>? data;
|
||
|
final MetaDto? meta;
|
||
|
|
||
|
const CharactersDto({this.data, this.meta});
|
||
|
|
||
|
factory CharactersDto.fromJson(Map<String, dynamic> json) =>
|
||
|
_$CharactersDtoFromJson(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;
|
||
|
|
||
|
PaginationDto({this.current, this.next, this.last});
|
||
|
|
||
|
factory PaginationDto.fromJson(Map<String, dynamic> json) =>
|
||
|
_$PaginationDtoFromJson(json);
|
||
|
}
|
||
|
|
||
|
@JsonSerializable(createToJson: false)
|
||
|
class CharacterDto {
|
||
|
final String? id;
|
||
|
final String? type;
|
||
|
final CharacterAttributesDto? attributes;
|
||
|
|
||
|
const CharacterDto({this.id, this.type, this.attributes});
|
||
|
|
||
|
factory CharacterDto.fromJson(Map<String, dynamic> json) =>
|
||
|
_$CharacterDtoFromJson(json);
|
||
|
}
|
||
|
|
||
|
@JsonSerializable(createToJson: false)
|
||
|
class CharacterAttributesDto {
|
||
|
final String? name;
|
||
|
final String? born;
|
||
|
final String? died;
|
||
|
final String? image;
|
||
|
|
||
|
const CharacterAttributesDto({this.name, this.born, this.died, this.image});
|
||
|
|
||
|
factory CharacterAttributesDto.fromJson(Map<String, dynamic> json) =>
|
||
|
_$CharacterAttributesDtoFromJson(json);
|
||
|
}
|