PathPolicy class final

The rules that turn raw path strings into canonical TreePaths and TreePaths into node identities.

A policy answers three questions for a tree: which characters separate segments (backslashIsSeparator), whether README.md and readme.md are the same node (caseSensitive), and how Unicode spellings are unified (unicodeNormalizer). Every path in one tree is parsed by the same policy, configured through TreeOptions.paths.

The default policy (const PathPolicy()) is case sensitive, like Linux and most POSIX file systems. Use PathPolicy.caseInsensitive for trees that mirror Windows or default macOS volumes.

Parsing never touches the file system and does not depend on the host platform, so C:\a parses the same on Linux, Windows, and the web.

Annotations

Constructors

PathPolicy({bool caseSensitive = true, bool backslashIsSeparator = true, String unicodeNormalizer(String path)?})
Creates a policy.
const

Properties

backslashIsSeparator → bool
Whether \ separates segments in addition to /.
final
caseSensitive → bool
Whether paths that differ only in letter case are different nodes.
final
hashCode → int
The hash code for this object.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
unicodeNormalizer → String Function(String path)?
A function applied to every raw path before parsing, typically Unicode NFC normalization from a package of your choice.
final

Methods

idOf(TreePath path) → NodeId
The identity key of path under this policy.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse(String path) → TreePath
Parses path into a canonical TreePath.
toString() → String
A string representation of this object.
override
tryParse(String path) → TreePath?
Parses path like parse, returning null when it is invalid.

Operators

operator ==(Object other) → bool
Whether other is a PathPolicy with equal settings.
override

Constants

caseInsensitive → const PathPolicy
A case-insensitive policy that otherwise uses the defaults.