Ruwan Sampath
Apr 27, 2021

--

How to get user inputs with flutter

  1. First you need to Create object of TextEditingController as a global variable in your State class

final emailController = new TextEditingController();

2. Then set it into your TextField widget

TextField(
controller: emailController, //as this line
obscureText: true,
textAlign: TextAlign.left,
decoration: InputDecoration(
border: InputBorder.none,
hintText: ‘PLEASE ENTER YOUR EMAIL’,
hintStyle: TextStyle(color: Colors.grey),
),
)

3. Now you can get the value from anywhere using,

emailController.text;

--

--

Ruwan Sampath
Ruwan Sampath

No responses yet