UriPattern class
A compiled path template such as /users/{id}/posts/{slug} that matches
concrete request paths and extracts the named segment parameters.
Routers everywhere re-implement this with ad-hoc splitting or a hand-rolled
regex. This keeps it segment-based (no regex surprises) and supports a typed
constraint: {id:int} only matches a segment that parses as an integer, so
/users/abc will not match /users/{id:int}. Captured values are the raw
path segments (not percent-decoded) — decode at the call site if needed.
Example:
UriPattern('/users/{id:int}/posts/{slug}').match('/users/42/posts/hello');
// {id: '42', slug: 'hello'}
Constructors
- UriPattern(String template)
-
Compiles
templateinto matchable segments. Leading/trailing slashes and empty segments are ignored, so/a/b/anda/bcompile identically. Audited: 2026-06-12 11:26 EDT
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
match(
String path) → Map< String, String> ? -
Matches
pathagainst this template. Returns the captured params keyed by name, or null when the path does not match — a different segment count, a literal segment mismatch, or a typed param whose value fails its constraint. A template with no params returns an empty map on a match. Audited: 2026-06-12 11:26 EDT -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited