find function
Get the first file that matches pattern in root.
rootの中にあるpatternに最初に当てはまるファイルを取得します。
Implementation
Future<File?> find(
Directory root,
Pattern pattern, {
bool recursive = true,
}) async {
final files = root.list(recursive: recursive);
await for (final file in files) {
final name = file.path.trimQuery().last();
final match = pattern.allMatches(name);
if (match.isEmpty) {
continue;
}
return File(file.path);
}
return null;
}