getCachePath method

Future<File> getCachePath({
  1. required String filename,
  2. String? directory,
})

获取缓存路径 filename 文件的名字,需要带上后缀(例如: eg.png) directory 二级子目录,不要带/

Implementation

Future<File> getCachePath(
    {required String filename, String? directory}) async {
  try {
    var dir = await getApplicationCacheDirectory();
    return _getFile(dir, directory, filename);
  } catch (e) {
    return File(filename);
  }
}