attach method
- @mustCallSuper
@mustCallSuper, inherited
Called by the host StatefulWidget
to attach a FocusNode
to the
widget tree.
In order to attach a FocusNode
to the widget tree, call attach,
typically from the StatefulWidget
's State.initState
method.
If the focus node in the host widget is swapped out, the new node will
need to be attached. FocusAttachment.detach
should be called on the old
node, and then attach called on the new node. This typically happens in
the State.didUpdateWidget
method.
Implementation
@mustCallSuper
FocusAttachment attach(BuildContext context, {FocusOnKeyCallback onKey}) {
_context = context;
_onKey = onKey ?? _onKey;
_attachment = FocusAttachment._(this);
return _attachment;
}