Repository navigation
Focus based navigation needs to have the widget Rect. #30084
Description
Activity
- addeda: desktopRunning on desktopRunning on desktopframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.c: API breakBackwards-incompatible API changesBackwards-incompatible API changes
on Mar 28, 2019 - added 2 commits that reference this issue
on Apr 22, 2019 Error: The method 'reparentIfNeeded' isn't defined for the class 'FocusScopeNode'.
- 'FocusScopeNode' is from 'package:flutter/src/widgets/focus_manager.dart' ('file:///Users/Macro/Documents/Flutter/flutter/packages/flutter/lib/src/widgets/focus_manager.dart').
Try correcting the name to the name of an existing method, or defining a method named 'reparentIfNeeded'.
FocusScope.of(context).reparentIfNeeded(context,node);
how to modify it ? thank you
tip: [✓] Flutter (Channel stable, v1.7.8+hotfix.3, on Mac OS X 10.13.6 17G65, locale zh-Hans-CN)- 'FocusScopeNode' is from 'package:flutter/src/widgets/focus_manager.dart' ('file:///Users/Macro/Documents/Flutter/flutter/packages/flutter/lib/src/widgets/focus_manager.dart').
@xiaoxiaohaozi, you need to use a
FocusAttachmentinstead. See the documentation forFocusNodefor an example. The focus system has changed quite a lot sincereparentIfNeededwas used. You might also consider switching to use the newFocusorFocusScopewidgets to manage the focus node for you.This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Aug 29, 2021
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.reparentIfNeededtakes only theFocusNodethat it will reparent. In order to provide services needed for keyboard focus traversal, this method will need to provide aBuildContextin order to be able to measure its size and location when determining the next widget to traverse to.We propose to break the
FocusScopeNodeAPI by changing it's signature from:to
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:
You would instead call: