RestorationStrategy enum

Defines the strategy used to serialize and deserialize a route for state restoration.

What This Enum Represents

When Flutter needs to save your app's navigation state (for example, when the operating system terminates your app to free memory), each route in the navigation stack must be converted to a format that can be persisted. This enum determines which serialization strategy ZenRouter uses for a particular route type.

The Two Strategies

unique - URI-based serialization: This strategy serializes routes by converting them to their URI representation using RouteUnique.toUri. The URI string is saved, and during restoration, the string is parsed back into a route using your coordinator's Coordinator.parseRouteFromUri method. This is the default and simplest strategy, suitable for routes where all necessary information can be encoded in the URL path and query parameters.

converter - Custom serialization: This strategy uses a custom RestorableConverter that you implement to serialize and deserialize the route. This is necessary when your route contains complex data that cannot (or should not) be represented in a URI, such as in-memory objects, computed state, or data that's too large for a URL.

When to Use Each Strategy

Use unique when:

  • Your route can be fully represented by its URI (path and query parameters)
  • You want the simplest implementation with no custom serialization code
  • The route's state can be reconstructed from the URL alone
  • Examples: /home, /products/123, /search?q=laptop

Use converter when:

  • Your route contains complex objects that can't be in a URL
  • You need to preserve in-memory state like form data or user selections
  • The amount of data is too large to reasonably fit in a URL
  • You want explicit control over what gets saved and restored
  • Examples: Routes with shopping cart items, complex filter objects, or rich text content

See also:

Inheritance
Available extensions

Values

unique → const RestorationStrategy
converter → const RestorationStrategy

Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
name String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
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

Constants

values → const List<RestorationStrategy>
A constant List of the values in this enum, in order of their declaration.