Reputation: 1757
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?
Upvotes: 14
Views: 12379
Reputation: 34769
There is a onSubmitted
property which accepts a ValueChanged
callback. onSubmitted
is triggered once the user press done after editing.
Hope that helps!
Upvotes: 23