glob
2.2.0, released 3 months ago by tools.dart.dev
A file and directory globbing library that supports Bash-style path matching and listing.
Rock solid
What it does
Performs Bash-style file and directory globbing in Dart. It allows developers to check whether a path matches a specific pattern, or recursively list filesystem entities matching a glob pattern using POSIX path syntax.
AI-written summary of version 2.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to filter files or paths using wildcards like `*` or `**`
- You want to recursively list files in a directory matching specific extensions or patterns
Skip it when
- You only need basic path manipulation provided natively by `package:path`
- You need complex recursive directory traversal without glob pattern matching
Strengths
- Supports familiar Bash-style glob syntax including wildcards, character ranges, and option expansion
- Works consistently across cross-platform environments using POSIX path syntax
- Integrates seamlessly with `package:file` for filesystem operations
Weaknesses
- Combinatorial option expansions exceeding 10,000 branches will throw a FormatException
- Requires using specific imports or a FileSystem object for filesystem listing APIs since version 2.0.0
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 5
none
import 'package:glob/glob.dart';
final dartFile = Glob("**.dart");
void main(List<String> arguments) {
for (var argument in arguments) {
if (dartFile.matches(argument)) print(argument);
}
}Works with
Packages commonly used together with glob: ones it builds on, ones built on it, and its own family.
- asyncglob depends on itUtility classes and helpers that extend Dart's async library.
- string_scannerglob depends on itA class for parsing strings using a sequence of patterns.
- fileglob depends on itPluggable, mockable file system abstraction for Dart with in-memory support.
- yamlSame familyA Dart library for parsing YAML documents into Dart data structures.
- ioSame familyUtilities for the Dart VM Runtime including ANSI colors, file copying, and exit code values.
- test_apiSame familyThe user facing API for structuring Dart tests and checking expectations.
- processSame familyPluggable, mockable process invocation abstraction for Dart.
- boolean_selectorSame familyParses and evaluates simplified Dart-like boolean expression strings.