I am using textformfield
in flutter. Whenever user types something I give him suggestion. When user taps on suggestion, keyboard is dismissed automatically. I want to stop keyboard from getting dismissed. How to do it? I want user to add suggestion continuously.
Thanks in advance.
3
Answers
You probably have this on
Or final FocusNode textFieldFocusNode = FocusNode();
Give FocusNode to Textformfield and focus that particular node on tapping of suggestion like this:
From the
FocusNode
documentation:So you can
addListener
to it to track changes that happens to it when you assign thatFocusNode
to theTextFormField
:You can add the listener, then check if it has focus, which means that you’re checking if the
TextFormField
field is focused, which also means that if the keyboard is shown:by this, it will remain the
TextFormField
focused, when you’re done with it, you can call theremoveListener()
.