Skip to content

Focus based navigation needs to have the widget Rect. #30084

@gspencergoog

Description

@gspencergoog

In order to be able to perform focus-based navigation, it is necessary to know the size and location of widgets that might be traversed to.

This is a tracking issue for the breaking change needed to collect this information, in order to fix #1608.

Currently, FocusScopeNode.reparentIfNeeded takes only the FocusNode that it will reparent. In order to provide services needed for keyboard focus traversal, this method will need to provide a BuildContext in order to be able to measure its size and location when determining the next widget to traverse to.
We propose to break the FocusScopeNode API by changing it's signature from:

void reparentIfNeeded(FocusNode node);

to

void reparentIfNeeded(BuildContext context, FocusNode node);

To modify code to compile again after this change, you would need to add a context argument to the call.  Typically, this method is called from a build method in order to keep the focus tree up to date with the widget tree, so instead of calling:

FocusScope.of(context).reparentIfNeeded(focusNode);

You would instead call:

FocusScope.of(context).reparentIfNeeded(context, focusNode);

Metadata

Metadata

Assignees

Labels

a: desktopRunning on desktopc: API breakBackwards-incompatible API changesframeworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions