summaryrefslogtreecommitdiff
path: root/lib/models/popular_detail.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/models/popular_detail.dart')
-rw-r--r--lib/models/popular_detail.dart83
1 files changed, 83 insertions, 0 deletions
diff --git a/lib/models/popular_detail.dart b/lib/models/popular_detail.dart
new file mode 100644
index 0000000..8b158ac
--- /dev/null
+++ b/lib/models/popular_detail.dart
@@ -0,0 +1,83 @@
+import 'package:pmsna1/models/popular_credit.dart';
+import 'package:pmsna1/models/popular_video.dart';
+
+class Genre {
+ int? id;
+ String? name;
+}
+
+class PopularDetail {
+ bool? adult;
+ String? backdropPath;
+ int? budget;
+ List<Genre>? genres;
+ String? homepage;
+ int? id;
+ String? originalLanguage;
+ String? overview;
+ double? popularity;
+ String? posterPath;
+ String? releaseDate;
+ int? revenue;
+ int? runtime;
+ String? tagline;
+ String? title;
+ bool? video;
+ double? voteAverage;
+ double? voteCount;
+ List<PopularVideo> videos;
+ List<PopularCredit> credits;
+
+ bool hasFavorite = false;
+
+ PopularDetail({
+ this.adult,
+ this.backdropPath,
+ this.budget,
+ this.genres,
+ this.homepage,
+ this.id,
+ this.originalLanguage,
+ this.overview,
+ this.popularity,
+ this.posterPath,
+ this.releaseDate,
+ this.revenue,
+ this.runtime,
+ this.tagline,
+ this.title,
+ this.video,
+ this.voteAverage,
+ this.voteCount,
+ this.videos = const [],
+ this.credits = const [],
+ });
+
+ factory PopularDetail.fromMap(Map<String, dynamic> map) {
+ return PopularDetail(
+ adult: map['adult'],
+ backdropPath: map['backdrop_path'],
+ id: map['id'],
+ originalLanguage: map['original_language'],
+ overview: map['overview'],
+ popularity: map['popularity'],
+ posterPath: map['posterPath'],
+ releaseDate: map['releaseDate'],
+ revenue: map['revenue'],
+ runtime: map['runtime'],
+ tagline: map['tagline'],
+ title: map['title'],
+ video: map['video'],
+ voteAverage: (map['vote_average'] is int)
+ ? (map['vote_average'] as int).toDouble()
+ : map['vote_average'],
+ voteCount: map['voteCount'],
+ videos: (map['videos']['results'] as List<dynamic>)
+ .map((v) => PopularVideo.fromMap(v))
+ .toList(),
+ credits: (map['credits']['cast'] as List<dynamic>)
+ .map((c) => PopularCredit.fromMap(c))
+ .toList(),
+ );
+ }
+}