Complete the code to create a text input field that captures user input.
TextField(controller: [1])The controller property needs a TextEditingController instance to capture and manage the input text.
Complete the code to read the current text from the input controller.
String userInput = [1].text;The text property of the TextEditingController instance holds the current input string.
Fix the error in the code to update the UI when the user types in the input field.
myController.[1](() {
setState(() {});
});onChanged on the controller instead of the TextField widget.text as a method.The addListener method registers a callback to run when the text changes, allowing UI updates.
Fill both blanks to create a TextField that updates a variable when the user types.
TextField(onChanged: ([1]) { [2] = [1]; })
The onChanged callback provides the new input as value, which we assign to inputText to store the user data.
Fill all three blanks to create a controller, assign it to a TextField, and dispose it properly.
final [1] = TextEditingController(); @override void dispose() { [1].[2](); super.dispose(); } Widget build(BuildContext context) { return TextField(controller: [3]); }
You create a controller named myController, dispose it in the dispose() method to free resources, and assign it to the TextField.