I have a TextField
in Flutter of which I want to automatically select the text and show the keyboard.
I can select the text through a TextEditingController
, but even with a FocusNodes
requestFocus the keyboard isn't shown, when the Widget opens.
How to automatically open the keyboard for a TextField?
TextField is a very common widget in Flutter. When you click on the TextField it opens up the on-screen keyboard. To hide/dismiss the keyboard you have to press the back button in Android and the done button (inside the onscreen keyboard) in iOS.
You can use the autofocus:true
property of the TextField:
Whether this text field should focus itself if nothing else is already focused.
So whenever the widget appears on screen, if theres nothing else with the keyboard focus, the focus will automatically be directed to it, thus opening the keyboard.
TextField(TextEditingController: controller,
focusNode: focusNode,
autofocus:true)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With