GlobFilter constructor

GlobFilter(
  1. String pattern, {
  2. bool? caseSensitive,
  3. bool isDirectory(
    1. String path
    )?,
  4. bool? isWindows,
})

Creates new glob filter.

Parameters: pattern Pattern for this glob filter. caseSensitive True, if the pattern is case sensitive; otherwise false. isDirectory Function that determines that specified path is a directory or not. isWindows True, if used the path in the Windows style; otherwise false.

Implementation

GlobFilter(this.pattern,
    {bool? caseSensitive,
    bool Function(String path)? isDirectory,
    bool? isWindows}) {
  if (isDirectory == null) {
    throw ArgumentError.notNull('isDirectory');
  }

  if (isWindows == null) {
    throw ArgumentError.notNull('isWindows');
  }

  if (caseSensitive == null) {
    if (isWindows) {
      caseSensitive = false;
    } else {
      caseSensitive = true;
    }
  }

  _isDirectory = isDirectory;
  _isWindows = isWindows;
  _glob = Glob(pattern, caseSensitive: caseSensitive);
  _onlyDirectory = false;
  final segments = _glob.segments!;
  if (segments.isNotEmpty) {
    _onlyDirectory = segments.last.onlyDirectory;
  }
}