How to get the TextField value in flutter

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

final TextEditingController emailController = TextEditingController();
@override
  void dispose() {
    // Clean up the controller when the widget is disposed.
    emailController.dispose();
    super.dispose();
  }
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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)