createDirIfNotExist function

Future<Directory> createDirIfNotExist(
  1. String dirPath
)

Creates Directory in the given dirPath if not exists

Implementation

Future<Directory> createDirIfNotExist(String dirPath) async {
  final dir = Directory(path.joinAll(path.split(dirPath)));
  // existsSync is intentional: this is on the CLI startup path where blocking
  // briefly is preferable to the overhead of a microtask. Image I/O hot paths
  // use the async equivalents.
  if (!dir.existsSync()) {
    await dir.create(recursive: true);
  }
  return dir;
}