projectRoot method

Future<String?> projectRoot()

Implementation

Future<String?> projectRoot() async {
  var dir = fileSystem.currentDirectory;

  while (true) {
    if (await dir.childFile('pubspec.yaml').exists()) {
      return dir.path;
    }

    if (dir.parent.path == dir.path) {
      break;
    }

    dir = dir.parent;
  }

  return null;
}