Answers for "get data from textfield flutter"

1

flutter textformfield value

1. Create a TextEditingController
final myController = TextEditingController();
  
2. Supply the TextEditingController to a TextField
TextField(
  controller: myController,
);
// or textformfield
TextFormField(
  controller: myController,
);
 
3. Display the current value of the text field
print("Value from TextFiled or TextFormField: ${myController.text}");
Posted by: Guest on October-30-2021
0

flutter how to get a value from text widget

String txt =  '';

@override
Widget build(BuildContext context) {
return Column(
	Children <Widget>[
    Text(txt), // this will store the text from somewhere and save it in to txt
    SizedBox(height: 15),
    ElevatedButton(
    onPressed () {
    // we can then call txt to see if the value is correct
    print(txt.tostring); //.tostring may not be necessary
    }
    ),
    ]
  ); 
}
Posted by: Guest on March-17-2021

Code answers related to "get data from textfield flutter"

Code answers related to "Dart"

Browse Popular Code Answers by Language