cachedFile method

Future<File?> cachedFile(
  1. String id, {
  2. ImageSize size = ImageSize.md,
})

Implementation

Future<File?> cachedFile(
  String id, {
  ImageSize size = ImageSize.md,
}) async {
  if (kIsWeb) {
    return null;
  }
  FileInfo? info = await cacheFileInfo(id);
  if (info == null) {
    return null;
  }
  Directory dir = await getApplicationCacheDirectory();
  var pathfile = "${dir.path}/${_id(id, size)}";
  final file = File(pathfile);
  if (await file.exists() && await file.length() > 0) {
    _cachedFiles[_id(id, size)] = pathfile;
    return file;
  }
  return null;
}