Line data Source code
1 : import 'package:tech_proof/core/services/local_storage_service.dart'; 2 : 3 : class MovieEntity implements JsonConvertible { 4 : final int id; 5 : final String posterPath; 6 : final String title; 7 : final String releaseDate; 8 : final String synopsis; 9 : final double rating; 10 : final List<String> genres; 11 : 12 14 : const MovieEntity({ 13 : required this.id, 14 : required this.posterPath, 15 : required this.title, 16 : required this.releaseDate, 17 : required this.synopsis, 18 : required this.rating, 19 : required this.genres, 20 : }); 21 0 : @override 22 : Map<String, dynamic> toJson() { 23 0 : return { 24 0 : 'id': id, 25 0 : 'posterPath': posterPath, 26 0 : 'title': title, 27 0 : 'releaseDate': releaseDate, 28 0 : 'synopsis': synopsis, 29 0 : 'rating': rating, 30 0 : 'genres': genres, 31 : }; 32 : } 33 : 34 0 : factory MovieEntity.fromJson(Map<String, dynamic> json) { 35 0 : return MovieEntity( 36 0 : id: json['id'] as int, 37 0 : posterPath: json['posterPath'] as String, 38 0 : title: json['title'] as String, 39 0 : releaseDate: json['releaseDate'] as String, 40 0 : synopsis: json['synopsis'] as String, 41 0 : rating: json['rating'] as double, 42 0 : genres: List<String>.from(json['genres'] as List), 43 : ); 44 : } 45 : }