54 lines
1.5 KiB
Dart
54 lines
1.5 KiB
Dart
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;
|
|
|
|
const GamesDto({this.data});
|
|
|
|
factory GamesDto.fromJson(Map<String, dynamic> json) => _$GamesDtoFromJson(json);
|
|
}
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
class GameDto {
|
|
//для rawg, для получения описания игры
|
|
@JsonKey(name: 'id')
|
|
final int? id;
|
|
|
|
final String? name;
|
|
|
|
final String? description;
|
|
|
|
|
|
@JsonKey(name: 'background_image')
|
|
final String? image;
|
|
|
|
// @JsonKey(name: 'original_release_date')
|
|
@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);
|
|
}
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
class GameInfoDto extends GameDto{
|
|
GameInfoDto(super.id, super.name, super.description, super.image, super.date);
|
|
|
|
}
|
|
|
|
// giant bomb
|
|
// @JsonSerializable(createToJson: false)
|
|
// class ImageDto {
|
|
// @JsonKey(name: 'original_url')
|
|
// final String? originalUrl;
|
|
//
|
|
// const ImageDto({this.originalUrl});
|
|
//
|
|
// factory ImageDto.fromJson(Map<String, dynamic> json) => _$ImageDtoFromJson(json);
|
|
// } |