DartProject.fromPath constructor

DartProject.fromPath(
  1. String pathToSearchFrom, {
  2. bool search = true,
})

Load a dart project from the given directory.

We search up the tree starting from pathToSearchFrom until we find a pubspec.yaml and that becomes the project root directory. If we don't find a pubspec.yaml then pathToSearchFrom is returned as the project root. If you want to test whether you are in a Dart project then use findProject. Set search to false if you don't want to search up the directory tree for a pubspec.yaml.

Implementation

DartProject.fromPath(String pathToSearchFrom, {bool search = true}) {
  _pathToProjectRoot =
      _findProject(pathToSearchFrom, search: search) ?? pathToSearchFrom;
  verbose(() => 'DartProject.fromPath: $pathToProjectRoot');
}