of static method

FocusScopeNode of(
  1. BuildContext context, {
  2. bool createDependency = true,
})
override

Returns the FocusNode.nearestScope of the Focus or FocusScope that most tightly encloses the given context.

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

If createDependency is true (which is the default), calling this function creates a dependency that will rebuild the given context when the focus node gains or loses focus.

Implementation

static FocusScopeNode of(BuildContext context, { bool createDependency = true }) {
  return Focus.maybeOf(context, scopeOk: true, createDependency: createDependency)?.nearestScope
      ?? context.owner!.focusManager.rootScope;
}