Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter: Unfocus on textfield (multiline) when keyboard is dismissed via back button press

Tags:

People also ask

How do you prevent the keyboard pushes a widget up on Flutter?

You can solve this problem by setting resizeToAvoidBottomInset: false in Scaffold() .

How do you Unfocus text field Flutter?

Try setting focus on the four text fields by selecting them, and then select "UNFOCUS" to see what happens when the current FocusManager. primaryFocus is unfocused.


I have the following TextFormField:

TextFormField(
  focusNode: inputFocusNode, 
  keyboardType: TextInputType.multiline,
  maxLines: null,
  minLines: 3,
)

When the textfield is on focus, the keyboard appears. When the phone back button is pressed, the keyboard disappears however the cursor on the textfield still remains.

I know you can use FocusScope.of(context).unfocus() to remove the cursor or unfocus. However there doesn't seem to be a direct way to detect the keyboard dismissal without getting a package

How do I address this issue?