-
Notifications
You must be signed in to change notification settings - Fork 26.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add high-level documentation and examples on managing keyboard focus. #45076
Comments
Thanks for filing this with the comprehensive list, @mleonhard. I've added it to our task list, and we will definitely address this. |
I'm working on developing some of the additional docs and examples that are needed, but some of your use cases are currently not supported by Flutter: Determining when the keyboard is visible and update the display accordingly.The software keyboard on Android doesn't give any event when it is hidden by the user. The view insets get updated, but it's a generic size update, and we don't have any way to know if it was because of the keyboard disappearing or not. Regardless, we've been able to detect the keyboard state in some apps by looking at the Keeping the keyboard on screenKeeping the keyboard on the screen if it's already visible is something we should be able to do, but it's not currently supported by the framework. We have a On Android, it's not possible to force the keyboard to be shown, since the user can dismiss the keyboard. Dismissing the software keyboard on non-Android platforms.Yes, iOS does have a way to dismiss the keyboard, but we don't have an API for it yet. Some of these related issues might be of interest to you: |
For "How to use Focus and FocusScope to control focus in an application with multiple widgets.", what kinds of control are you referring to? Here's what I was going to start with:
But your request is somewhat general, so I'm not sure what specifics you were missing, or use cases you wanted to see and didn't find. |
@mleonhard, when you say "How to provide expected software keyboard decorations to move from one widget to the next.", are you referring to the "->" (next) button on the software keyboards, or something else? |
Greg, Thank you for taking a look at this issue. "How to use Focus and FocusScope to control focus in an application with multiple widgets." Let me share my concrete use cases. Our app has a sign up screen with a phone number text field, a "Send Verification Code" button, and a "verification code" text field.
"How to provide expected software keyboard decorations to move from one widget to the next." Yes, this is the bar that appears in iOS above the keyboard. I would like to see a We need a way to implement '⌃' and '⌄' buttons. This will require a way to specify an ordered set of focusable widgets. How about The 'Done' button is important since #21814 is still not fixed. I would like a documented convention for which component is responsible for scrolling a focused widget into view, one of: the widget receiving focus, the code that changes focus, the enclosing scrollable container, the Flutter |
@mleonhard , for focusing other widgets, I can see that could be an issue if you have to jump around a lot. Is the reason you have to focus other widgets directly because you can't control the focus traversal order easily/well enough? I envisioned that most of the time in this kind of case you would just call FYI, I've just submitted #49235 for review, which allows definition of an explicit order for widgets easily, and refactors the If you want to focus widgets based on a global key, you can do that, but for things that have their GlobalKey myGlobalKey = GlobalKey():
...
Widget build(BuildContext context) {
return FlatButton(child: Text("Click Me", key: myGlobalKey), onPressed: () {});
}
...
// somewhere else
Focus.of(myGlobalKey.currentContext).requestFocus(); I'll add an example of that. The downside of using Also, you shouldn't need to use |
As for what has responsibility for scrolling something into view (calling |
I think most of these are addressed now. I'm going to close this, and if you have specific additional issues, please file them separately so we can prioritize appropriately. Thanks for reporting this! |
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 |
Use case
My app must manage focus and the on-screen keyboard. I read the provided documentation:
I found the provided documentation to be missing key information:
My app requires all of these use-cases. So far, I have made-do with reading Flutter's source code (a huge time sink), stackoverflow answers, and snippets shared in Flutter issues. My implementations are unsatisfactory in many ways. Today I have just wasted 2 hours trying to solve the problem of keeping the keyboard on screen on iOS, still with no solution. Focus management is an area where I have sunk a lot of time working around missing parts of Flutter. It has been and continues to be a struggle, a large energy sink. I want to be building features and solving problems for my users, not fighting against the UX framework.
I think better documentation would help me and other app developers to arrive at good solutions quickly.
Proposal
Please allocate some time to writing some high-level documentation on managing keyboard focus in Flutter.
The text was updated successfully, but these errors were encountered: