Create and style a text field

Retrieve the value of a text field

Handle changes to a text field

Cookbook

Forms

Handle changes to a text field

1. Supply an onChanged() callback to a TextField or a TextFormField

2. Use a TextEditingController

Create a TextEditingController
Connect the TextEditingController to a text field
Create a function to print the latest value
Listen to the controller for changes

Interactive example

In some cases, it’s useful to run a callback function every time the text
in a text field changes. For example, you might want to build a search
screen with autocomplete functionality where you want to update the
results as the user types.

How do you run a callback function every time the text changes?
With Flutter, you have two options:

Supply an onChanged() callback to a TextField or a TextFormField.