findFiles static method
An async Stream of File instances found responsive to the matcher
within the rootDir
/subPath
location on the file system. THe rootDir
will default to Directory.current if not provided
Implementation
static Stream<File> findFiles({
String? subPath,
String? rootDir,
RegExp? matcher,
}) async* {
final finalRoot = rootDir ?? Directory.current.path;
final finalSub = subPath ?? '';
final finalPath = path.join(finalRoot, finalSub);
final baseDir = Directory(finalPath);
if (baseDir.existsSync()) {
await for (var entry in baseDir.list(recursive: true)) {
if (entry is File &&
(matcher == null || matcher.hasMatch(entry.path))) {
yield entry;
}
}
}
}