Glob class

A glob for matching and listing files and directories.

A glob matches an entire string as a path. Although the glob pattern uses POSIX syntax, it can match against POSIX, Windows, or URL paths. The format it expects paths to use is based on the context parameter to new Glob; it defaults to the current system's syntax.

Paths are normalized before being matched against a glob, so for example the glob foo/bar matches the path foo/./bar. A relative glob can match an absolute path and vice versa; globs and paths are both interpreted as relative to context.current, which defaults to the current working directory.

When used as a Pattern, a glob will return either one or zero matches for a string depending on whether the entire string matches the glob. These matches don't currently have capture groups, although this may change in the future.

Implemented types


Glob(String pattern, {Context context, bool recursive: false, bool caseSensitive})
Creates a new glob with pattern. [...]


caseSensitive bool
Whether the glob matches paths case-sensitively.
context Context
The context in which paths matched against this glob are interpreted.
hashCode int
The hash code for this object. [...]
read-only, inherited
pattern String
The pattern used to create this glob.
recursive bool
If true, a path matches if it matches the glob itself or is recursively contained within a directory that matches.
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


allMatches(String path, [int start = 0]) Iterable<Match>
Match this pattern against the string repeatedly. [...]
list({String root, bool followLinks: true}) Stream<FileSystemEntity>
Lists all FileSystemEntitys beneath root that match the glob. [...]
listSync({String root, bool followLinks: true}) List<FileSystemEntity>
Synchronously lists all FileSystemEntitys beneath root that match the glob. [...]
matchAsPrefix(String path, [int start = 0]) Match
Match this pattern against the start of string. [...]
matches(String path) bool
Returns whether this glob matches path.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toString() String
Returns a string representation of this object.


operator ==(dynamic other) bool
The equality operator. [...]

Static Methods

quote(String contents) String
Returns contents with characters that are meaningful in globs backslash-escaped.