createDirSync method

Future<Directory?> createDirSync(
  1. String path
)

异步创建目录(命名带 Sync 后缀但实为 async;path 为空返回 null)。

Implementation

Future<Directory?> createDirSync(String path) async {
  if (path.isEmpty) {
    return null;
  }
  Directory dir = Directory(path);
  final bool exist = await dir.exists();
  if (!exist) {
    dir = await dir.create(recursive: true);
  }
  return dir;
}