getProjectDirectory method

String getProjectDirectory()

Get current project directory

Implementation

String getProjectDirectory() {
  var current = Directory.current.path;
  while (current != path.dirname(current)) {
    if (File(path.join(current, 'pubspec.yaml')).existsSync()) {
      return current;
    }
    current = path.dirname(current);
  }
  throw Exception('Not in a Dart/Flutter project directory');
}