import 'package:json_annotation/json_annotation.dart'; part 'movies_dto.g.dart'; @JsonSerializable(createToJson: false) class MoviesDto { final List? docs; final MoviePaginationDto? pagination; const MoviesDto({this.docs, this.pagination}); factory MoviesDto.fromJson(Map json) => _$MoviesDtoFromJson(json); } @JsonSerializable(createToJson: false) class MoviePaginationDto { @JsonKey(name: 'current_page') final int? currentPage; @JsonKey(name: 'has_next_page') final bool? hasNextPage; @JsonKey(name: 'last_visible_page') final int? lastVisiblePage; const MoviePaginationDto({this.currentPage, this.hasNextPage, this.lastVisiblePage}); factory MoviePaginationDto.fromJson(Map json) => _$MoviePaginationDtoFromJson(json); } @JsonSerializable(createToJson: false) class MovieDataDto { @JsonKey(name: 'id') final int? id; final String? name; final String? description; final PosterDto? poster; @JsonKey(name: 'year', defaultValue: 0) final int year; final List? genres; final List? countries; const MovieDataDto( this.name, this.description, this.poster, { this.id, this.year = 0, this.genres, this.countries, }); factory MovieDataDto.fromJson(Map json) => _$MovieDataDtoFromJson(json); } @JsonSerializable(createToJson: false) class GenreDto { final String? name; const GenreDto({this.name}); factory GenreDto.fromJson(Map json) => _$GenreDtoFromJson(json); } @JsonSerializable(createToJson: false) class CountryDto { final String? name; const CountryDto({this.name}); factory CountryDto.fromJson(Map json) => _$CountryDtoFromJson(json); } @JsonSerializable(createToJson: false) class PosterDto { final String? url; final String? previewUrl; const PosterDto({this.url, this.previewUrl}); factory PosterDto.fromJson(Map json) => _$PosterDtoFromJson(json); }