listAssetsFor method
Lists all assets in the specified packages
.
For each package, this method collects all files from relevant directories. For the root package, this includes all directories specified in PackageFileResolver.dirsScheme. For non-root packages, only files in the 'lib' directory are collected.
Returns a map where keys are package names and values are lists of Asset objects.
Implementation
Map<String, List<Asset>> listAssetsFor(Set<String> packages) {
final Map<String, List<Asset>> assets = HashMap<String, List<Asset>>();
for (final String package in packages) {
final List<Asset> collection = <Asset>[];
final String packagePath = fileResolver.pathFor(package);
final Directory dir = Directory(p.fromUri(packagePath));
assert(dir.existsSync(), 'Package $package not found at ${dir.path}');
for (final String subDir in PackageFileResolver.dirsScheme.keys) {
/// Skip none-lib directory for non-root packages
if (subDir != 'lib' && package != fileResolver.rootPackage) continue;
final Directory subDirPath = Directory(p.join(dir.path, subDir));
if (subDirPath.existsSync()) {
_collectAssets(subDirPath, collection);
}
}
assets[package] = collection;
}
return assets;
}