getToWatch method

Future<List<Movie>> getToWatch({
  1. bool forceRefresh = false,
})

Retrieves the list of to-watch movies from POD cache.

Implementation

Future<List<Movie>> getToWatch({bool forceRefresh = false}) async {
  // Read from MovieList file instead of cached old TTL data.

  if (_toWatchListId != null) {
    final movieListData = await _movieListService
        .getMovieList(_toWatchListId!, forceRefresh: forceRefresh);
    if (movieListData != null) {
      final movies = movieListData['movies'] as List<Movie>? ?? [];
      return List.from(movies);
    }
  }

  // Fallback to cached data if MovieList fails.

  if (_cachedToWatch != null) {
    return List.from(_cachedToWatch!);
  }

  // Final fallback to SharedPreferences.

  return _fallbackService.getToWatch();
}