of method Null safety

FocusScopeNode of(
  1. BuildContext context
)
override

Returns the FocusScopeNode of the FocusScope that most tightly encloses the given context.

If this node doesn't have a Focus widget ancestor, then the FocusManager.rootScope is returned.

The context argument must not be null.

Implementation

static FocusScopeNode of(BuildContext context) {
  assert(context != null);
  final _FocusMarker? marker = context.dependOnInheritedWidgetOfExactType<_FocusMarker>();
  return marker?.notifier?.nearestScope ?? context.owner!.focusManager.rootScope;
}