Mobiles_programming/lib/data/dto/games_dto.dart

40 lines
1.1 KiB
Dart
Raw Normal View History

2024-11-15 21:47:58 +04:00
import 'package:json_annotation/json_annotation.dart';
//автоматически сгенерился
part 'games_dto.g.dart';
// createToJson:false - указание, что сериализатор не нужен, нужен только десериализатор
@JsonSerializable(createToJson: false)
class GamesDto {
@JsonKey(name: 'results')
final List<GameDto>? data;
final int? current;
final int? next;
// final int? previous;
const GamesDto({this.data, this.current, this.next});
2024-11-15 21:47:58 +04:00
factory GamesDto.fromJson(Map<String, dynamic> json) => _$GamesDtoFromJson(json);
}
@JsonSerializable(createToJson: false)
class GameDto {
//для получения описания игры
2024-11-15 21:47:58 +04:00
@JsonKey(name: 'id')
final int? id;
final String? name;
final String? description;
@JsonKey(name: 'background_image')
final String? image;
@JsonKey(name: 'released')
final String? date;
const GameDto(this.id, this.name, this.description, this.image, this.date);
factory GameDto.fromJson(Map<String, dynamic> json) => _$GameDtoFromJson(json);
}