NavigateToIndexedStackNodeGuard class
Keeps an IndexedStack parent node aligned with a fixed set of tab routes:
every declared route appears exactly once as a child, order may change
(for example when ActiveRouteController reorders tabs), and
arguments, extra, and nested child state on existing nodes are kept
when nodes are added or removed.
Behavior
When the guard runs against the IndexedStack node for its configured route:
- If that node is absent from the tree → GuardResult.next.
- If the configured declared-route list is empty → GuardResult.cancel.
- If children are missing, duplicated, or include undeclared routes → GuardResult.redirect with a repaired child list.
- If the structure already matches the declaration → GuardResult.next.
Invariants
Shape
- The node has exactly one child per declared route (same cardinality as the declaration).
- Every child route appears in the declared set; extra child routes are not allowed.
- Child order is unconstrained so tab reordering stays valid.
Preservation
- For routes that remain before and after the fix,
RouteNode.arguments,RouteNode.extra, and deeper navigation state under those nodes are retained where possible.
Example
const guard = NavigateToIndexedStackNodeGuard(
route: Routes.tabBar,
declaredRoutes: [Routes.home, Routes.profile, Routes.settings],
);
// If tabBar has only home and profile, the guard adds settings.
// If tabBar has home, an undeclared route, and profile, the guard removes
// the undeclared branch while preserving arguments/extra on the rest.
- Implemented types
- Annotations
Constructors
-
Keeps an IndexedStack parent node aligned with a fixed set of tab routes:
every declared route appears exactly once as a child, order may change
(for example when ActiveRouteController reorders tabs), and
arguments,extra, and nested child state on existing nodes are kept when nodes are added or removed.const
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
-
call(
RouteNode origin, RouteNode target, GuardContext context) → GuardResult -
Invoked when the RouteNode state is about to change.
override
-
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