RouteStackUri class

Codec for serializing a list of route URIs into a single URL and back — used by RouteController when UrlStrategy.stacked is enabled.

Wire format: <route-1>[;<q1>]+<route-2>[;<q2>]+...+<top>[;<qN>][?<topQuery>]

  • The path concatenates each route's path joined by +. + is a sub-delim under RFC 3986 and is preserved as a literal character in URI paths (it's only special inside the query component, where it stands in for a space).
  • A route's own queryParameters serialize as a ;key=value&key=value matrix clause appended to that route's path segment. ; is also a sub-delim, allowed in paths without encoding. Values are percent- encoded so &/=/;/+/spaces inside a value can't break parsing.
  • The TOP route additionally accepts the standard ? clause at the end of the URL. This lets Uri.parse(stackUrl).queryParameters keep working as a no-op view onto the active route's params for any external code that hasn't learned about stacked URLs. When both a ; clause AND the standard ? are present on the top route, they are merged (? keys win on conflict).

Round-trip examples:

[/home]                        ↔ /home
[/home?a=1]                    ↔ /home?a=1
[/home, /sheet]                ↔ /home+/sheet
[/home, /sheet?tab=2]          ↔ /home+/sheet?tab=2
[/home?a=1, /sheet?b=2]        ↔ /home;a=1+/sheet?b=2
[/a?x=1, /b?y=2, /c?z=3]       ↔ /a;x=1+/b;y=2+/c?z=3

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

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

Static Methods

decode(Uri uri) → List<Uri>
Decodes a stack URI into its component route URIs.
decodeSegments(String input) → List<Uri>
Inverse of encodeSegments. Parses a +-separated route list (with ;-prefixed per-route matrix queries) into a list of Uris. Empty input yields an empty list; empty segments are defensively skipped.
encode(List<Uri> routes) → Uri
Encodes routes as a single stack URI.
encodeSegments(List<Uri> routes) → String
Encodes routes as a +-separated string with each route's queryParameters serialized inline via the matrix-style ; clause (no standard ? top-route special-case).
isStacked(Uri uri) → bool
Whether uri is shaped like a stack-encoded URL (contains the delimiter in its path). Used by RouteController to decide whether a given URL is a flat single-route URL or a stack URL.

Constants

delimiter → const String
The single character that separates route paths inside the encoded path. Apps must not register routes whose own path contains this delimiter (asserted by RouteController).
querySeparator → const String
The character that separates a route's path from its inline (matrix- style) query inside a single segment of the stack URL.