@@ -4,13 +4,6 @@ part 'movie_responses.g.dart';
44
55@JsonSerializable ()
66class MoviesResponse {
7- final int page;
8- final List <Movie > results;
9- @JsonKey (name: 'total_pages' )
10- final int totalPages;
11- @JsonKey (name: 'total_results' )
12- final int totalResults;
13-
147 MoviesResponse ({
158 required this .page,
169 required this .results,
@@ -20,12 +13,30 @@ class MoviesResponse {
2013
2114 factory MoviesResponse .fromJson (Map <String , dynamic > json) =>
2215 _$MoviesResponseFromJson (json);
16+ final int page;
17+ final List <Movie > results;
18+ @JsonKey (name: 'total_pages' )
19+ final int totalPages;
20+ @JsonKey (name: 'total_results' )
21+ final int totalResults;
2322
2423 Map <String , dynamic > toJson () => _$MoviesResponseToJson (this );
2524}
2625
2726@JsonSerializable ()
2827class Movie {
28+ Movie ({
29+ required this .id,
30+ required this .title,
31+ required this .voteAverage,
32+ required this .overview,
33+ this .posterPath,
34+ this .backdropPath,
35+ this .releaseDate,
36+ this .genreIds,
37+ });
38+
39+ factory Movie .fromJson (Map <String , dynamic > json) => _$MovieFromJson (json);
2940 final int id;
3041 final String title;
3142 @JsonKey (name: 'poster_path' )
@@ -37,70 +48,51 @@ class Movie {
3748 @JsonKey (name: 'vote_average' )
3849 final double voteAverage;
3950 final String overview;
40-
41- Movie ({
42- required this .id,
43- required this .title,
44- this .posterPath,
45- this .backdropPath,
46- this .releaseDate,
47- required this .voteAverage,
48- required this .overview,
49- });
50-
51- factory Movie .fromJson (Map <String , dynamic > json) => _$MovieFromJson (json);
51+ @JsonKey (name: 'genre_ids' )
52+ final List <int >? genreIds;
5253
5354 Map <String , dynamic > toJson () => _$MovieToJson (this );
5455}
5556
5657@JsonSerializable ()
5758class MovieDetailsResponse extends Movie {
58- final List <Genre > genres;
59- final int runtime;
60- @JsonKey (name: 'production_companies' )
61- final List <ProductionCompany > productionCompanies;
62-
6359 MovieDetailsResponse ({
6460 required super .id,
6561 required super .title,
66- super .posterPath,
67- super .backdropPath,
68- super .releaseDate,
6962 required super .voteAverage,
7063 required super .overview,
7164 required this .genres,
7265 required this .runtime,
7366 required this .productionCompanies,
67+ super .posterPath,
68+ super .backdropPath,
69+ super .releaseDate,
7470 });
7571
7672 factory MovieDetailsResponse .fromJson (Map <String , dynamic > json) =>
7773 _$MovieDetailsResponseFromJson (json);
74+ final List <Genre > genres;
75+ final int runtime;
76+ @JsonKey (name: 'production_companies' )
77+ final List <ProductionCompany > productionCompanies;
7878
7979 @override
8080 Map <String , dynamic > toJson () => _$MovieDetailsResponseToJson (this );
8181}
8282
8383@JsonSerializable ()
8484class Genre {
85- final int id;
86- final String name;
87-
8885 Genre ({required this .id, required this .name});
8986
9087 factory Genre .fromJson (Map <String , dynamic > json) => _$GenreFromJson (json);
88+ final int id;
89+ final String name;
9190
9291 Map <String , dynamic > toJson () => _$GenreToJson (this );
9392}
9493
9594@JsonSerializable ()
9695class ProductionCompany {
97- final int id;
98- final String name;
99- @JsonKey (name: 'logo_path' )
100- final String ? logoPath;
101- @JsonKey (name: 'origin_country' )
102- final String originCountry;
103-
10496 ProductionCompany ({
10597 required this .id,
10698 required this .name,
@@ -110,43 +102,41 @@ class ProductionCompany {
110102
111103 factory ProductionCompany .fromJson (Map <String , dynamic > json) =>
112104 _$ProductionCompanyFromJson (json);
105+ final int id;
106+ final String name;
107+ @JsonKey (name: 'logo_path' )
108+ final String ? logoPath;
109+ @JsonKey (name: 'origin_country' )
110+ final String originCountry;
113111
114112 Map <String , dynamic > toJson () => _$ProductionCompanyToJson (this );
115113}
116114
117115@JsonSerializable ()
118116class GenresResponse {
119- final List <Genre > genres;
120-
121117 GenresResponse ({required this .genres});
122118
123119 factory GenresResponse .fromJson (Map <String , dynamic > json) =>
124120 _$GenresResponseFromJson (json);
121+ final List <Genre > genres;
125122
126123 Map <String , dynamic > toJson () => _$GenresResponseToJson (this );
127124}
128125
129126@JsonSerializable ()
130127class CreditsResponse {
131- final List <Cast > cast;
132- final List <Crew > crew;
133-
134128 CreditsResponse ({required this .cast, required this .crew});
135129
136130 factory CreditsResponse .fromJson (Map <String , dynamic > json) =>
137131 _$CreditsResponseFromJson (json);
132+ final List <Cast > cast;
133+ final List <Crew > crew;
138134
139135 Map <String , dynamic > toJson () => _$CreditsResponseToJson (this );
140136}
141137
142138@JsonSerializable ()
143139class Cast {
144- final int id;
145- final String name;
146- final String character;
147- @JsonKey (name: 'profile_path' )
148- final String ? profilePath;
149-
150140 Cast ({
151141 required this .id,
152142 required this .name,
@@ -155,19 +145,17 @@ class Cast {
155145 });
156146
157147 factory Cast .fromJson (Map <String , dynamic > json) => _$CastFromJson (json);
148+ final int id;
149+ final String name;
150+ final String character;
151+ @JsonKey (name: 'profile_path' )
152+ final String ? profilePath;
158153
159154 Map <String , dynamic > toJson () => _$CastToJson (this );
160155}
161156
162157@JsonSerializable ()
163158class Crew {
164- final int id;
165- final String name;
166- final String department;
167- final String job;
168- @JsonKey (name: 'profile_path' )
169- final String ? profilePath;
170-
171159 Crew ({
172160 required this .id,
173161 required this .name,
@@ -177,6 +165,12 @@ class Crew {
177165 });
178166
179167 factory Crew .fromJson (Map <String , dynamic > json) => _$CrewFromJson (json);
168+ final int id;
169+ final String name;
170+ final String department;
171+ final String job;
172+ @JsonKey (name: 'profile_path' )
173+ final String ? profilePath;
180174
181175 Map <String , dynamic > toJson () => _$CrewToJson (this );
182- }
176+ }
0 commit comments