createStorageDir static method

Future<Directory?> createStorageDir({
  1. required String dirName,
})

dirName 文件夹名 category 分类,例如:video,image等等 String path = StorageUtil.getStoragePath(fileName: 'yc.apk', dirName: 'apk');

Implementation

static Future<Directory?> createStorageDir({required String dirName}) async {
  Directory? _storageDir = await _initStorageDir();
  if (_storageDir == null) {
    return null;
  }
  StringBuffer sb = StringBuffer("${_storageDir.path}");
  if (!ObjectUtils.isEmpty(dirName)) {
    sb.write("/$dirName");
  }
  return createDir(sb.toString());
}