of method Null safety
- BuildContext context
Finds the FocusOrder in the nearest ancestor FocusTraversalOrder widget.
It does not create a rebuild dependency because changing the traversal order doesn't change the widget tree, so nothing needs to be rebuilt as a result of an order change.
If no FocusTraversalOrder ancestor exists, or the order is null, this will assert in debug mode, and throw an exception in release mode.
Implementation
static FocusOrder of(BuildContext context) {
assert(context != null);
final FocusTraversalOrder? marker = context.getElementForInheritedWidgetOfExactType<FocusTraversalOrder>()?.widget as FocusTraversalOrder?;
assert(() {
if (marker == null) {
throw FlutterError(
'FocusTraversalOrder.of() was called with a context that '
'does not contain a FocusTraversalOrder widget. No TraversalOrder widget '
'ancestor could be found starting from the context that was passed to '
'FocusTraversalOrder.of().\n'
'The context used was:\n'
' $context',
);
}
return true;
}());
return marker!.order;
}