read method
Implementation
@override
Future<CachedAssetEntry?> read(String sourceUri) async {
if (_loadedKeys.contains(sourceUri)) {
return _entries[sourceUri];
}
_loadedKeys.add(sourceUri);
final metadataFile = _metadataFileFor(sourceUri);
if (!await metadataFile.exists()) {
return null;
}
try {
final decoded = jsonDecode(await metadataFile.readAsString());
if (decoded is! Map) {
await _deleteEntryFiles(sourceUri);
return null;
}
final entry = CachedAssetEntry.fromJson(
decoded.map((key, value) => MapEntry(key.toString(), value)),
);
if (!await File(entry.filePath).exists()) {
await _deleteEntryFiles(sourceUri);
return null;
}
_entries[sourceUri] = entry;
return entry;
} catch (_) {
await _deleteEntryFiles(sourceUri);
return null;
}
}