Home » Android » android – How to get the TextField value in flutter

android – How to get the TextField value in flutter

Posted by: admin April 23, 2020 Leave a comment


Hi I have created sign up screen in the flutter. I want to get the email and password in the onPressed of the FlatButton.

Does anyone know how to do this in flutter ?

How to&Answers:

Create your TextEditingController as a global variable in your State class and set it into your TextField widget.

Now you can get the value using :

You can get more information here: https://flutter.dev/docs/cookbook/forms/retrieve-input


The text field calls the onChanged callback whenever the user changes the text in the field. If the user indicates that they are done typing in the field (e.g., by pressing a button on the soft keyboard), the text field calls the onSubmitted callback.

Using this callbacks, we can set the instance variables and use those variables on onPress of submit button.