onChanged property Null safety

ValueChanged<String>? onChanged

Called when the user initiates a change to the TextField's value: when they have inserted or deleted text.

This callback doesn't run when the TextField's text is changed programmatically, via the TextField's controller. Typically it isn't necessary to be notified of such changes, since they're initiated by the app itself.

To be notified of all changes to the TextField's text, cursor, and selection, one can add a listener to its controller with TextEditingController.addListener.

This example shows how onChanged could be used to check the TextField's current value each time the user inserts or deletes a character.
To create a local project with this code sample, run:
flutter create --sample=widgets.EditableText.onChanged.1 mysample

See also:


final ValueChanged<String>? onChanged;