pathFromRoot static method

String pathFromRoot(
  1. KnownPaths type, [
  2. String? rootDir,
  3. bool create = true
])

Gets a path from within the rootDir for the specified type, this will optionally create the directory if it doesn't already exist.

Implementation

static String pathFromRoot(KnownPaths type,
    [String? rootDir, bool create = true]) {
  final safeRoot = rootDir ?? Directory.current.path;
  final typePath = relativePathRoots[type];
  final typeDir = path.normalize(path.join(safeRoot, typePath));
  if (create && !Directory(typeDir).existsSync()) {
    Directory(typeDir).createSync(recursive: true);
  }
  return typeDir;
}