getCachedImageFile function
Get the local file of the cached image
Implementation
Future<File?> getCachedImageFile(String url, {String? cacheKey}) async {
try {
final String key = cacheKey ?? keyToMd5(url);
final Directory cacheImagesDirectory = Directory(
join((await getTemporaryDirectory()).path, cacheImageFolderName));
if (cacheImagesDirectory.existsSync()) {
await for (final FileSystemEntity file in cacheImagesDirectory.list()) {
if (file.path.endsWith(key)) {
return File(file.path);
}
}
}
} catch (_) {
return null;
}
return null;
}