packagesIn function
Every package directory directly under root that carries a pubspec.yaml.
Implementation
List<Pubspec> packagesIn(String root) {
final dir = Directory(root);
if (!dir.existsSync()) return const [];
final found = <Pubspec>[];
for (final entity in dir.listSync().whereType<Directory>()) {
final pubspec = Pubspec.read(entity.path);
if (pubspec != null) found.add(pubspec);
}
found.sort((a, b) => a.name.compareTo(b.name));
return found;
}