Input widgets and forms
The ability of your app to manage gestures is a good starting point for interaction with the user, but for many apps, you also need a way to get other types of input from a user. Getting user data is what allows for custom content and customization in your app.
Flutter provides many input data widgets to help developers get different kinds of information from the user. We saw some of them in Chapter 5, Building Your User Interface through Widgets, including TextField, and different kinds of Selector and Picker widgets.
Getting input through the onChanged callback
A TextField widget lets the user enter text with a keyboard. The TextField widget exposes the onChanged parameter, which takes a function and can be used to listen for changes in its current value. This is the simplest way to track the text within TextField and behaves much like the onPressed example we saw earlier in this chapter:
TextField(
onChanged: (text) {
...