childrenOf method
finds all children that match the given file name, starts from the current directory and traverses down
Implementation
Future<List<String>> childrenOf(
String fileName, {
String? directoryPath,
}) async {
final children = <String>[];
final directory = directoryPath != null
? fs.directory(directoryPath)
: fs.currentDirectory;
final glob = Glob('**$fileName', recursive: true);
final entities = glob.listFileSystemSync(
fs,
followLinks: false,
root: directory.path,
);
for (final entity in entities) {
if (entity is! File) continue;
if (entity.basename != fileName) continue;
children.add(entity.path);
}
return children;
}