简体   繁体   中英

How can i send data to textfield in flutter

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'),

              ),

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM