getCachedMoviesForCategory method

Future<List<Movie>?> getCachedMoviesForCategory(
  1. CacheCategory category
)

Get cached movies for a specific category.

Implementation

Future<List<Movie>?> getCachedMoviesForCategory(
  CacheCategory category,
) async {
  await _ensureInitialized();
  try {
    final cachedData = _movieBox!.get(category.value);
    if (cachedData == null) return null;

    // Convert dynamic list back to Movie list.

    return cachedData.cast<Movie>();
  } catch (e) {
    debugPrint('Error retrieving cached movies for ${category.value}: $e');
    return null;
  }
}