getMovies method

Future<List<Movie>> getMovies([
  1. MovieFilters? filters
])

Implementation

Future<List<Movie>> getMovies([MovieFilters? filters]) async {
  filters ??= MovieFilters();
  final response = await query('discover/movie', HttpMethod.get, constructQuery(filters));

  if (response.statusCode == 200) {
    final List<Movie> movies = List<Movie>.from(response.data["results"].map((x) => Movie.fromJson(x)));
    return movies.where((movie) => movie.language == filters!.language).toList();
  } else {
    // If the server did not return a 200 OK response,
    // then throw an exception.
    throw Exception('Failed to load movies');
  }
}