To access the focus node from an ancestor of the Focus widget, create and pass
in a FocusNode as the Focus widget’s focusNode attribute. Because it needs
to be disposed of, the focus node you pass needs to be owned by a stateful
widget, so don’t just create one each time it is built.

Builder to make sure you have
the correct context. This is shown in the following example:

Timing

One of the details of the focus system is that when focus is requested, it only
takes effect after the current build phase completes.  This means that focus
changes are always delayed by one frame, because changing focus can
cause arbitrary parts of the widget tree to rebuild, including ancestors of the
widget currently requesting focus. Because descendants cannot dirty their
ancestors, it has to happen between frames, so that any needed changes can
happen on the next frame.

FocusScope widget