getToWatch method

  1. @override
Future<List<Movie>> getToWatch()
override

Retrieves the list of to-watch movies.

Implementation

@override
Future<List<Movie>> getToWatch() async {
  // Check if cache is valid.

  if (_cachedToWatch != null &&
      _toWatchCacheTime != null &&
      DateTime.now().difference(_toWatchCacheTime!) < _userDataTtl) {
    return List.from(_cachedToWatch!);
  }

  // Cache miss or expired - fetch from manager.

  final movies = await _manager.getToWatch();

  // Update cache.

  _cachedToWatch = List.from(movies);
  _toWatchCacheTime = DateTime.now();

  return movies;
}