findRootAssets method
Finds assets in the root package that match the specified matcher
pattern.
This method recursively searches all directories in the root package
and returns a list of Asset objects for files that match the matcher
.
The subDir
parameter allows filtering assets within a specific subdirectory
of the root package. If subDir
is provided, it should be a relative path
from the root package directory.
Implementation
List<Asset> findRootAssets(PathMatcher matcher, {String? subDir}) {
final String package = fileResolver.rootPackage;
final String packagePath = fileResolver.pathFor(package);
final Directory dir = Directory(p.fromUri(p.join(packagePath, subDir)));
assert(dir.existsSync(), 'Package $package not found at ${dir.path}');
final List<Asset> collection = <Asset>[];
_collectAssets(dir, collection, matcher: matcher);
return collection;
}