Using Text Field widget an app can interact with user input. So how do we get the value from the widget ?
There are two ways, one is use change event to store values to a local final variable using SetState of the widget and the second is try using Editing-Controller, which can also offer service like clearing box etc. I go with controller.
Controller
Create a text editing controller and attach it to the widget
final mycontroller = TextEditingController();
attach the controller to the widget and it will look like the following
child: TextField( decoration: InputDecoration(hintText: 'Enter todo here'), controller: mycontroller, onChanged: (value) {}, ),
Using the controller
You can use the controller to access the data and clear the data as follows
OutlineButton( onPressed: () { var newtodo = new Todo(mycontroller.text); text.clear(); })
Flutter Projects

Flutter-Kitchen-Cart
A firebase – Flutter sample application for iOS and Android

Flutter Project Planner
A MongoDB-Flutter cloud application for project management

Hivedb-Flutter Todo
This project store todo items locally using NoSQL database, Hivedb, which is written in dart. Damn blazingly fast
One thought on “Accessing value from a Text Field in Flutter”