onEditingComplete property

VoidCallback? onEditingComplete
final

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.

onChanged is called before onSubmitted when user indicates completion of editing, such as when pressing the "done" button on the keyboard. That default behavior can be overridden. See onEditingComplete for details.

{@tool dartpad} This example shows how onChanged could be used to check the TextField's current value each time the user inserts or deletes a character.

** See code in examples/api/lib/widgets/editable_text/editable_text.on_changed.0.dart ** {@end-tool}

See also:

  • inputFormatters, which are called before onChanged runs and can validate and change ("format") the input value.
  • onEditingComplete, onSubmitted: which are more specialized input change notifications. Called when the user submits editable content (e.g., user presses the "done" button on the keyboard).

The default implementation of onEditingComplete executes 2 different behaviors based on the situation:

  • When a completion action is pressed, such as "done", "go", "send", or "search", the user's content is submitted to the controller and then focus is given up.

  • When a non-completion action is pressed, such as "next" or "previous", the user's content is submitted to the controller, but focus is not given up because developers may want to immediately move focus to another input widget within onSubmitted.

Providing onEditingComplete prevents the aforementioned default behavior.

Implementation

// final ValueChanged<String>? onChanged;

/// {@macro flutter.widgets.editableText.onEditingComplete}
final VoidCallback? onEditingComplete;