getMovieDetails method
Implementation
Future<Movie> getMovieDetails(Movie movie) async {
MovieFilters filters = MovieFilters();
filters.language = 'en-US';
try {
final response = await query('movie/${movie.id}', HttpMethod.get, constructQuery(filters));
if (response.statusCode == 200) {
var responseDetails = response.data;
movie.runtime = responseDetails['runtime'];
movie.posterPath = 'https://image.tmdb.org/t/p/original${responseDetails['poster_path']}';
movie.backdropPath = 'https://image.tmdb.org/t/p/original${responseDetails['backdrop_path']}';
movie.title = responseDetails['title'];
movie.releaseDate = DateTime.parse(responseDetails['release_date']);
movie.overview = responseDetails['overview'];
movie.voteAverage = responseDetails['vote_average'];
}
return movie;
} catch (e) {
throw Exception('Failed to load movie details');
}
}