RouterNode class

A stack of RouteNodes.

The RouteNode children are the stack, bottom to top. The operations are:

  • go replaces the entire stack with its route.
  • push adds a route to the top of the stack.
  • pop removes a route from the top of the stack.

Leaving the router is leaving the tree, so routes respond to routing through the usual build and mount signals. Routes are built by the caller; the router keeps no registry.

Scheduling

Added nodes only hit the tree on the next frame, so a push or go begins at the call but holds until its route is in the tree, so nothing moves before the next frame, even if the router itself has yet to update. A pop starts at the call, since its route is already in the tree.

Region

The region routed is the shape in effect above this node, or the scene's when nothing spatial is above. The routes and any transition chrome will fill that region. A sized SpatialNode parent scopes the router to a subregion, such as a HUD switching between town and combat panels.

Concurrent Navigation

When navigating while another navigation is already running, the router will settle the running navigation first, except that a pop during a running navigation plays it back instead. Settling snaps the running transition to its end.

Inheritance
Available extensions

Constructors

RouterNode({Transition? transition, Shape? shape, Vector2? position, Vector2? scale, double? angle, Anchor? anchor, bool? enabled, int? priority, Iterable<RouteNode>? children})

Properties

absoluteCenter → MVector2
The center of this node's shape in scene space.
no setterinherited
absolutePosition → MVector2
This node's position in scene space.
no setterinherited
activity ↔ Activity
What this node takes part in: ticking, rendering, and hearing input. Defaults to Activity.all.
getter/setter pairinherited
ancestors → Iterable<Node>
This node's ancestors in the tree.
no setterinherited
anchor ↔ Anchor
Where this node's area sits relative to position. Defaults to topLeft.
getter/setter pairinherited
angle ↔ double
This node's clockwise rotation, in radians. Defaults to 0.
getter/setter pairinherited
center → Vector2
The center of this node's shape, in its local space.
no setterinherited
children → Iterable<Node>
This node's direct children.
no setterinherited
descendants → Iterable<Node>
This node's descendants in depth-first preorder.
no setterinherited
enabled ↔ bool
Whether this node ticks, renders, and hears input, all three.
getter/setter pairinherited
flex → LayoutFlex
The share of a flex layout's leftover space this node asks for.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
hasParent → bool
True if this node has a non-null parent.
no setterinherited
height → double
This node's height.
no setterinherited
inherit → ShapeInheritance
What shape falls back to when this node states none. Defaults to ShapeInheritance.none.
finalinherited
isMounted → bool
True while this node is part of a mounted tree.
no setterinherited
isRemoving → bool
True while this node awaits removal at the next flush.
no setterinherited
isTransitioning → bool
Whether a navigation is running.
no setter
localTransform → MMatrix3
This node's local transform.
no setterinherited
onMount → Signal0
Emitted when this node is added to a scene.
finalinherited
onSceneResize → Signal1<Vector2>
Emitted when the scene resizes, and once at mount.
finalinherited
onUnmount → Signal0
Emitted when this node is removed from a scene.
finalinherited
parent → Node?
The parent that owns this node, or null when it is parentless.
no setterinherited
position → MVector2
This node's position. Defaults to (0, 0).
finalinherited
priority ↔ int
This node's order in updating and rendering in its parent. Defaults to 0.
getter/setter pairinherited
progress → double
The running navigation's progress, or 1 between navigations.
no setter
routes → Iterable<RouteNode>
The stack, bottom to top.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scale → MVector2
This node's scale. Defaults to (1, 1).
finalinherited
scene → Scene<Node>
This node's owning scene. Only valid while isMounted.
no setterinherited
shape ↔ Shape
This node's shape.
getter/setter pairinherited
size → Vector2
This node's dimensions, determined by the bounds of its shape.
no setterinherited
top → RouteNode?
The route on top, or null while the stack is empty.
no setter
transition → Transition
The transition a navigation plays when it names none.
final
width → double
This node's width.
no setterinherited

Methods

absoluteTransform([Node? upTo]) → MMatrix3
This node's transform composed with every SpatialNode ancestor, stopping at (but not including) upTo.
inherited
add<T extends Node>(T node) → T
Routes come and go through push, go, and pop alone.
override
addAll(Iterable<Node> nodes) → void
Adds all nodes to this node.
inherited
attach(Node node) → void
Adds this node to the target node.
inherited
build() → void
Declares this node's children and behavior.
override
contains(Node other) → bool
Checks if this node contains the other node in its tree.
inherited
containsPoint(Vector2 point) → bool
Whether this node's hit area contains point.
inherited
cycles(Node node) → bool
True if node is (or soon will be) an ancestor of this node.
inherited
debugDraw(DebugDraw draw) → void
Draws to the debug overlay every frame, in the same space as draw.
inherited
debugRender(Canvas canvas) → void
Renders the subtree under this node's transform, marking position with a 2-pixel cross before anything this node or its children draw.
inherited
debugRenderSelf(Canvas canvas) → void
Runs this node's debugDraw callbacks, in the same space as renderSelf.
inherited
detach() → bool
Removes this node from its parent, or from the parent it is on its way to.
inherited
disable() → void
Disables this node, so it stops updating, rendering and answering.
inherited
distance(SpatialNode other) → double
The distance between this node's absolute center and other's.
inherited
distance2(SpatialNode other) → double
The squared distance between this node's absolute center and other's.
inherited
draw(Draw draw) → void
Draws to canvas every frame, in this node's own coordinate space.
inherited
enable() → void
Enables this node, so it resumes updating, rendering and answering.
inherited
go(RouteNode route, {Transition? transition}) → Future<void>
Replaces the whole stack with route, playing transition over the route's own and the default, and completes once the navigation settles.
hitTest(Vector2 point) → Iterable<Node>
Finds every node in this subtree whose hit area contains point, per containsPoint, topmost first. A node hearing no input hides its whole subtree.
inherited
layout(LayoutConstraints constraints) → void
A node that can't lay itself out takes no part in it, so constraints change nothing.
inherited
mount() → Scene<T>

Available on T, provided by the Mount extension

Mounts this node as the root of a new Scene and returns it.
nearest<T extends SpatialNode>([Node? within]) → T?
The nearest T to this node among within's descendants, or null if there is none.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
owns(Node other) → bool
Checks if this node owns the other node.
inherited
pointAt(Anchor anchor) → Vector2
The anchor's point in this node's local space.
inherited
pop([Object? result]) → Future<void>
Plays the running navigation back, or with none running, plays the top route's push back, uncovering the route beneath and completing that push with result, which must be of the type it asked for. Completes once the navigation settles. Throws a StateError on an empty stack.
provide<T>(T value) → void
Provides value as this node's instance of T, overwriting any value previously provided for T.
inherited
push<R>(RouteNode route) → Future<R?>
Lays route over the top, playing the route's own transition over the default and leaving the route beneath to its backdrop.
query<T extends Node>() → Iterable<T>
This node's direct children of type T, in priority order.
inherited
read<T>() → T
As readOrNull, but throws a StateError when nothing provided T.
inherited
readOrNull<T>() → T?
Reads the nearest instance of T provided by this node or an ancestor, checking this node first. Returns null if none was provided.
inherited
remove(Node node) → bool
Routes come and go through push, go, and pop alone.
override
removeAll() → void
Removes all children.
inherited
render(Canvas canvas) → void
Renders this node and its children to canvas.
inherited
renderChildren(Canvas canvas) → void
Renders this node's enabled children to canvas, in priority order.
inherited
renderSelf(Canvas canvas) → void
Runs this node's draw callbacks.
inherited
scenePosition([Node? upTo]) → MVector2
This node's position, composed with the transform of every SpatialNode ancestor, stopping at (but not including) upTo.
inherited
tick(Tick tick) → void
Calls tick with the elapsed seconds on every frame.
inherited
toString() → String
A string representation of this object.
inherited
trash(Cleanup cleanup) → void
Defers cleanup until this build stops being current.
inherited
traverse({bool prune(Node node)?}) → Iterable<Node>
This node and its subtree, in postorder: every child before its parent, and children in reverse priority order.
inherited
update(double dt) → void
Updates this node and its children by dt seconds.
inherited
worldBounds(Shape shape, Matrix3 transform) → Aabb2
This node's world-space AABB for shape, given its already-computed transform (see absoluteTransform).
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited