[英]I want to get the value from a TextFormField when i press a RaisedButton in flutter
TextFormField has it's own property to perform actions, called "onFieldSubmited". TextFormField具有执行操作的专有属性,称为“ onFieldSubmited”。
But i want to get the value from the TextFormField, when i press a RaisedButton or something. 但是当我按下RaisedButton之类的东西时,我想从TextFormField中获取值。
How can i do it? 我该怎么做?
Use TextEditingController
to get the value of a specific TextField. 使用TextEditingController
获取特定TextField的值。
https://flutter.dev/docs/cookbook/forms/text-field-changes https://flutter.dev/docs/cookbook/forms/text-field-changes
[...]
TextEditingController controllername = TextEditingController();
[...]
TextField(
controller: controllername, //...Rest of the code
)
Use the controllername.value to get the current value of a Textfield for that particular moment. 使用controllername.value获取该特定时刻的文本字段的当前值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.