40 lines
1.1 KiB
Dart
40 lines
1.1 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;
|
|
|
|
final int? current;
|
|
final int? next;
|
|
// final int? previous;
|
|
|
|
const GamesDto({this.data, this.current, this.next});
|
|
|
|
factory GamesDto.fromJson(Map<String, dynamic> json) => _$GamesDtoFromJson(json);
|
|
}
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
class GameDto {
|
|
//для получения описания игры
|
|
@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);
|
|
} |