findPackages function
Implementation
Stream<Package> findPackages(Directory root) =>
findPackageDirectories(root).asyncMap(
(dir) async {
final pubspec = await PubSpec.load(dir);
final dirPath = dir.path;
final rootPath = root.path;
final rootIndex = rootPath.length;
final dirIndex = dirPath.lastIndexOf(Platform.pathSeparator);
return Package(
directory: dir,
namespace: dirPath.substring(
rootIndex == dirIndex ? rootIndex : rootIndex + 1,
dirIndex,
),
name: pubspec.name!,
isFlutter: pubspec.allDependencies.containsKey("flutter"),
pubspec: pubspec,
);
},
);