maybeOf method Null safety

FocusOrder? maybeOf(
  1. 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, returns null.

Implementation

static FocusOrder? maybeOf(BuildContext context) {
  assert(context != null);
  final FocusTraversalOrder? marker = context.getElementForInheritedWidgetOfExactType<FocusTraversalOrder>()?.widget as FocusTraversalOrder?;
  return marker?.order;
}