TextEditingController.addListener()
registers a callback for when the text changes. This seems to also be triggered by pressing the Enter button, opening/closing the keyboard (changing focus).
How do i register that it was the enter that was pressed so i can, for example, invoke an API?
The current way i achieve this is by listening on the FocusNode
to detect focus change. Focus is removed from the FocusNode
when pressing enter, and the keyboard closes. Is this the right way to do it?
For text entry, consider using a EditableText, which integrates with on-screen keyboards and input method editors (IMEs). Creates a widget that receives raw keyboard events. For text entry, consider using a EditableText, which integrates with on-screen keyboards and input method editors (IMEs).
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.
There is a onSubmitted
property which accepts a ValueChanged
callback. onSubmitted
is triggered once the user press done after editing.
Hope that helps!
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