getPersonalRating method
- Movie movie
Gets the personal rating for a movie from POD.
Implementation
Future<double?> getPersonalRating(Movie movie) async {
// First check cache.
if (_cachedRatings != null &&
_cachedRatings!.containsKey(movie.id.toString())) {
return _cachedRatings![movie.id.toString()];
}
// Try to read file - on first read after app restart, _moviesWithFiles will be empty.
// But we should still try to read existing files.
final movieData = await _readMovieFile(movie);
if (movieData != null && movieData['rating'] != null) {
final rating = movieData['rating'] as double?;
if (rating != null) {
// Cache the result and mark as having a file.
_cachedRatings ??= {};
_cachedRatings![movie.id.toString()] = rating;
_moviesWithFiles.add(movie.id);
return rating;
}
}
// No rating found - don't cache null values, just return null.
return null;
}