How to get the TextField value in flutter
another easier (for my opinion) option is to add 'onChanged' property inside the TextField class that will contain the String
String enteredText .... TextField( onChanged: (newText) { enteredText = newText; },
Create your TextEditingController
as a global variable in your State
class and set it into your TextField
widget.
TextEditingController emailController = new TextEditingController();
....
TextField(
controller: emailController,
obscureText: true,
textAlign: TextAlign.left,
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'PLEASE ENTER YOUR EMAIL',
hintStyle: TextStyle(color: Colors.grey),
),
)
Now you can get the value using :
emailController.text
You can get more information here: https://flutter.dev/docs/cookbook/forms/retrieve-input