How can i send data to textfield in flutter

Issue

Hello i am reading a barcode and if the barcode reader i would like set up the input of the Textfield the the data that i read but i couldn’t figured out how to do that here is my code

 TextField(
     textFieldData=readDataTurnString();
                keyboardType: TextInputType.emailAddress,
                textAlign: TextAlign.center,
                onChanged: (value) {},
                decoration: InputDecoration(hintText: 'Enter Your Public Key'),

              ),

Solution

You are do something like following:

TextEditingController _controller = new TextEditingController();

@override
Widget build(BuildContext context) {
...
    child: TextField(controller: _controller),
}

You can later use the _controller to set the value of Textfield like this:

_controller.text = "New Text Value";

Does this solve your problem?

Answered By – Anuroop Singh

Answer Checked By – Cary Denson (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.