find function
Find files and directories matching a glob pattern.
This function searches for files and directories that match the given glob pattern, providing flexible search capabilities.
Parameters:
pattern: Glob pattern to match (supports *, ?,abc,a-z,!abc)caseSensitive: Whether to perform case-sensitive matching (default: false)recursive: Whether to search subdirectories recursively (default: true)includeHidden: Whether to include hidden files/directories (default: false)workingDirectory: Directory to start search from (default: current directory)types: Types of file system entities to include (default: files only)
Returns a FindProgress object that can be used to iterate over results.
Supported glob patterns:
*- matches any number of characters?- matches any single character[abc]- matches any one character in the brackets[a-z]- matches any character in the range[!abc]- matches any character NOT in the brackets[!a-z]- matches any character NOT in the range
Example:
// Find all .dart files
find('*.dart').forEach(print);
// Find all files starting with 'test_'
find('test_*').forEach(print);
// Find directories only
find('*', types: [Find.directory]).forEach(print);
// Case-sensitive search
find('Test*', caseSensitive: true).forEach(print);
Implementation
FindProgress find(
String pattern, {
bool caseSensitive = false,
bool recursive = true,
bool includeHidden = false,
String workingDirectory = '.',
List<FileSystemEntityType> types = const [Find.file],
}) {
return FindProgress(
pattern,
caseSensitive: caseSensitive,
recursion: recursive,
includeHidden: includeHidden,
workingDirectory: workingDirectory,
types: types,
);
}