getCachedImageFile function

Future<File> getCachedImageFile (
  1. String url
)

get the local file of the cached image

Implementation

Future<File> getCachedImageFile(String url) async {
  try {
    final String key = keyToMd5(url);
    final Directory cacheImagesDirectory = Directory(
        join((await getTemporaryDirectory()).path, cacheImageFolderName));
    if (cacheImagesDirectory.existsSync()) {
      for (final FileSystemEntity file in cacheImagesDirectory.listSync()) {
        if (file.path.endsWith(key)) {
          return File(file.path);
        }
      }
    }
  } catch (_) {
    return null;
  }
  return null;
}