In flutter, When we edit a TextField and close soft-keyboard by touching outside, the cursor of TextField is showing and blinking
How can I exit editing mode when unfocused? i.e. keyboard is closed
In flutter, When we edit a TextField and close soft-keyboard by touching outside, the cursor of TextField is showing and blinking
How can I exit editing mode when unfocused? i.e. keyboard is closed
You can listen to keyboard close event via eg. flutter_keyboard_visibility and then call FocusScope.of(context).unfocus():
@override
void initState() {
super.initState();
KeyboardVisibility.onChange.listen((bool visible) {
if (!visible) FocusScope.of(context).unfocus();
});
}
If you already have your own way to detect that user is done with editing the text, then just call FocusScope.of(context).unfocus(); -- it will disable the cursor and close the keyboard.