includes method

bool includes(
  1. String otherPath, {
  2. required bool isDir,
})

Implementation

bool includes(String otherPath, {required bool isDir}) {
  final other = otherPath == '.' ? '' : otherPath;
  final self = (path == '.' ? '' : path).toAbsolute(p.isAbsolute(otherPath));
  if (exclusions.isNotEmpty) {
    if (isDir) {
      // check every sub-path of other path, not just the last one
      if (other.startsWith(self)) {
        for (final part in p.split(other.substring(self.length))) {
          if (exclusions.contains(part)) {
            return false;
          }
        }
      }
    } else if (exclusions.contains(p.basename(other))) {
      return false;
    }
  }
  if (!includeHidden && other.isHidden()) {
    return false;
  }
  return isDir || includesExtension(other);
}