Retrieve the value of a text field :
the Previous example, we have discussed entering the input text to the text field and validating that text field if it is empty. Now in this example, we are going to discuss how to retrieve the entered input value/text.
Follow the Below steps to retrieve entered input as output/ result in the flutter App:
- Create a
TextEditingController
- Supply the
TextEditingController
to aTextField
- Display the current value of the text file
Create a TextEditingController:
To retrieve the user entered input text as a result / out put , we have to create a TextEditingController
and then supply the TextEditingController
to a TextField
.
After supplying the TextEditingController
to a TextField
or TextFormField
, we can retrieve the user entered data as a out put/result.
Please Note: It is also important to dispose
of the TextEditingController
after getting the user entered input as output/result. in below code you will see disposing it by using dispose()