NavigationStack<T extends RouteTarget> class

A widget that renders a stack of pages based on a NavigationPath.

This is the core widget for imperative navigation. It listens to the path and updates the Navigator with the corresponding pages.

Role in Navigation Flow

NavigationStack is the visual representation of a NavigationPath:

  1. Listens to path changes via path listeners
  2. Uses Myers diff algorithm to calculate route changes
  3. Builds Page objects via the resolver callback
  4. Updates Flutter's Navigator with the page stack

The widget handles:

  • Page creation and disposal
  • Guard execution on pop attempts
  • Route result completion
  • State restoration
Inheritance

Constructors

const

Properties

coordinator Coordinator<RouteUnique>?
The associated coordinator
final
defaultRoute → T?
Optional route to push when the stack initializes.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
Optional key for accessing the navigator state.
final
observers List<NavigatorObserver>
A list of observers for this navigator.
final
parseRouteFromUri → T Function(Uri uri)?
final
path NavigationPath<T>
The navigation path to render.
final
resolver StackTransitionResolver<T>
Callback that converts routes to destinations.
final
restorationId String?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<NavigationStack<T>>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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

Static Methods

declarative<T extends RouteTarget>({required List<T> routes, required StackTransitionResolver<T> resolver, GlobalKey<NavigatorState>? navigatorKey, String? debugLabel, String? restorationId, T parseRouteFromUri(Uri uri)?}) DeclarativeNavigationStack<T>
Creates a declarative navigation stack.