maybeOf static method

AutofillGroupState? maybeOf(
  1. BuildContext context
)

Returns the AutofillGroupState of the closest AutofillGroup widget which encloses the given context, or null if one cannot be found.

Calling this method will create a dependency on the closest AutofillGroup in the context, if there is one.

An AutofillGroupState can be used to register an AutofillClient when it enters this AutofillGroup (for example, when an EditableText is mounted or reparented onto the AutofillGroup's subtree), and unregister an AutofillClient when it exits (for example, when an EditableText gets unmounted or reparented out of the AutofillGroup's subtree).

The AutofillGroupState class also provides an AutofillGroupState.attach method that can be called by TextInputClients that support autofill, instead of TextInput.attach, to create a TextInputConnection to interact with the platform's text input system.

See also:

Implementation

static AutofillGroupState? maybeOf(BuildContext context) {
  final _AutofillScope? scope = context.dependOnInheritedWidgetOfExactType<_AutofillScope>();
  return scope?._scope;
}