NavigationViewController class

Controls the state of a NavigationPane and NavigationView.

The selectedIndex property is the index of the currently selected navigation destination and the animation represents the current position of the pane's open/close state. The selected destination's index can be changed with selectDestinationByIndex.

A stateful widget that builds a NavigationPane or NavigationView can create a NavigationViewController and share it directly.

When the NavigationPane and NavigationView don't have a convenient stateful ancestor, a NavigationViewController can be shared by providing a NavigationViewController inherited widget.

Inheritance

Constructors

Creates a controller for NavigationPane and NavigationView.

Properties

animation Animation<double>?
An animation whose value represents the current position of the NavigationPane's open/close state.
no setter
animationController AnimationController
The underlying AnimationController used for pane animations.
no setter
animationDuration Duration
Controls the duration of pane open/close animations.
no setter
canGoBack bool
Checks if there's navigation history available to go back to.
no setter
currentSelection String?
Gets the current selection as a string representation.
no setter
destinationType DestinationTypes
Defines how destinations are selected and managed.
final
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
historyLength int
Gets the number of destinations in the navigation history.
no setter
isAnimating bool
Whether the pane is currently animating between open and closed states.
no setter
isPaneOpen bool
Whether the pane is currently open.
no setter
lastVisitedIndex int?
Gets the last visited index from the navigation history.
no setter
lastVisitedPath String?
Gets the last visited path from the navigation history.
no setter
length int
The total number of navigable destinations.
final
Gets the complete navigation history as a unified list.
no setter
offset double
The current offset of the pane animation.
getter/setter pair
onDestinationIndex DestinationSelectedIndex?
Callback that is called when a destination is selected.
final
onDestinationPath DestinationSelectedPath?
Callback that is called when a destination is selected.
final
previousIndex int?
The index of the previously selected navigation destination.
no setter
previousIndices List<int>
The list of previously visited navigation indices.
no setter
previousPaths List<String>
The list of previously visited navigation paths.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectedIndex int?
The index of the currently selected navigation destination.
getter/setter pair
selectedPath String?
The path of the currently selected navigation destination.
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
clearHistory() → void
Clears the navigation history without changing the current selection.
close({Duration? duration, Curve curve = Curves.easeInOut}) → void
Closes the navigation pane with an animation.
containsIndexInHistory(int index) bool
Checks if a specific index exists in the navigation history.
containsPathInHistory(String path) bool
Checks if a specific path exists in the navigation history.
createDestinationPathTapCallback(String path) VoidCallback?
Creates a callback for when a destination with the given path is tapped. Only available when destinationType is DestinationTypes.byPath.
createDestinationTapCallback(int index) VoidCallback?
Creates a callback for when a destination at the given index is tapped. Only available when destinationType is DestinationTypes.byIndex.
dispose() → void
Discards any resources used by the object.
override
fling({double velocity = 1.0}) → void
Flings the pane open or closed based on the given velocity.
getDestinationAnimation(int index) Animation<double>
Gets the selection animation for a specific destination index.
getIndexHistoryAt(int position) int?
Gets an index from the history at the specified position.
getPathHistoryAt(int position) String?
Gets a path from the history at the specified position.
goBack() bool
Navigates back to the previous destination in the history.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
open({Duration? duration, Curve curve = Curves.easeInOut}) → void
Opens the navigation pane with an animation.
removeIndexFromHistory(int index) bool
Removes a specific index from the navigation history.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
removePathFromHistory(String path) bool
Removes a specific path from the navigation history.
reset() → void
Resets the controller to its initial state based on destinationType.
selectDestinationByIndex(int index) → void
Selects a navigation destination by index.
selectDestinationByPath(String path) → void
Selects a navigation destination by path.
snapClosed() → void
Immediately sets the pane to the closed state without animation.
snapOpen() → void
Immediately sets the pane to the open state without animation.
toggle({Duration? duration, Curve curve = Curves.easeInOut}) → void
Toggles the navigation pane between open and closed states.
toString() String
A string representation of this object.
inherited

Operators

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