getCacheDirectory function

Future<Directory> getCacheDirectory(
  1. {String path = '',
  2. Future<Directory> directoryPath}
)

获取缓存文件夹

Implementation

Future<Directory> getCacheDirectory({String path = '', Future<Directory> directoryPath}) async{
  Directory filepath = isEmpty(directoryPath)? Platform.isAndroid? await getApplicationSupportDirectory() : await getTemporaryDirectory() : await directoryPath;
  PackageInfo packageInfo = await PackageInfo.fromPlatform();
  Directory directory = Directory(filepath.path + "/" + packageInfo.packageName + (isEmptyString(path)? '' : '/$path'));
  bool exists = await directory.exists();
  if (!exists) {
    await directory.create();
  }
  return directory;
}