OrderedTraversalPolicy class

A FocusTraversalPolicy that orders nodes by an explicit order that resides in the nearest FocusTraversalOrder widget ancestor.

Only orders of the same type are comparable. If a set of widgets in the same FocusTraversalGroup contains orders that are not comparable with each other, it will assert, since the ordering between such keys is undefined. To avoid collisions, use a FocusTraversalGroup to group similarly ordered widgets together.

When overriding, doCompare must be overridden instead of compareTo, which calls doCompare to do the actual comparison.

This sample shows how to assign a traversal order to a widget. In the example, the focus order goes from bottom right (the "One" button) to top left (the "Six" button).
To create a local project with this code sample, run:
flutter create --sample=widgets.OrderedTraversalPolicy.1 mysample

See also:

Mixed in types


OrderedTraversalPolicy({FocusTraversalPolicy secondary})
Constructs a traversal policy that orders widgets for keyboard traversal based on an explicit order. [...]


hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
secondary FocusTraversalPolicy
This is the policy that is used when a node doesn't have an order assigned, or when multiple nodes have orders which are identical. [...]


changedScope({FocusNode node, FocusScopeNode oldScope}) → void
This is called whenever the given node is re-parented into a new scope, so that the policy has a chance to update or invalidate any cached data that it maintains per scope about the node. [...]
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
@mustCallSuper, @protected, inherited
findFirstFocus(FocusNode currentNode) FocusNode
Returns the node that should receive focus if focus is traversing forwards, and there is no current focus. [...]
findFirstFocusInDirection(FocusNode currentNode, TraversalDirection direction) FocusNode
Returns the first node in the given direction that should receive focus if there is no current focus in the scope to which the currentNode belongs. [...]
findLastFocus(FocusNode currentNode) FocusNode
Returns the node that should receive focus if focus is traversing backwards, and there is no current focus. [...]
inDirection(FocusNode currentNode, TraversalDirection direction) bool
Focuses the next widget in the given direction in the FocusScope that contains the currentNode. [...]
@mustCallSuper, inherited
invalidateScopeData(FocusScopeNode node) → void
Clears the data associated with the given FocusScopeNode for this object. [...]
next(FocusNode currentNode) bool
Focuses the next widget in the focus scope that contains the given currentNode. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
previous(FocusNode currentNode) bool
Focuses the previous widget in the focus scope that contains the given currentNode. [...]
sortDescendants(Iterable<FocusNode> descendants, FocusNode currentNode) Iterable<FocusNode>
Sorts the given descendants into focus order. [...]
toDiagnosticsNode({String name, DiagnosticsTreeStyle style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. [...]
toString({DiagnosticLevel minLevel: DiagnosticLevel.info}) String
Returns a string representation of this object.
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode. [...]


operator ==(Object other) bool
The equality operator. [...]