getMovieComments method
- Movie movie
Gets the personal comments for a movie from POD.
Implementation
Future<String?> getMovieComments(Movie movie) async {
// First check cache.
if (_cachedComments != null &&
_cachedComments!.containsKey(movie.id.toString())) {
final cached = _cachedComments![movie.id.toString()];
return cached?.isNotEmpty == true ? cached : null;
}
// 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['comment'] != null) {
final comment = movieData['comment'] as String?;
if (comment != null && comment.isNotEmpty) {
// Cache the result and mark as having a file.
_cachedComments ??= {};
_cachedComments![movie.id.toString()] = comment;
_moviesWithFiles.add(movie.id);
return comment;
}
}
// No comment found - don't cache null values, just return null
return null;
}