简体   繁体   English

当我在颤抖中按下RaisedButton时,我想从TextFormField中获取值

[英]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? 我该怎么做?

All you need is a TextEditingController 您只需要一个TextEditingController

There is a cookbook for this in flutter's own website. 在flutter自己的网站上有一本食谱 Wonder how you missed 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.

相关问题 如何删除 Flutter 中 RaisedButton 的按下 animation? - How can I remove press animation of RaisedButton in Flutter? 我想验证 flutter 中的“文本”不是(TextFormField 或 Textfield) - I want to validate "Text" in flutter not (TextFormField or Textfield) 如何从 Flutter 上的 TextFormField 获取值 - How to get value from TextFormField on Flutter 需要您的支持:当我按下收藏按钮时,我想在我的 Flutter 数据库中获取产品 ID - Need your HELD : I want to get the product ID in my Flutter database when I press the favorite button Flutter - 当想要更改初始值时,TextFormField 崩溃应用程序 - Flutter - TextFormField Crash App When Want to Change Initial Value Flutter:TextFormField 和 RaisedButton alignment 在同一行 - Flutter: TextFormField and RaisedButton alignment on the same row 我想确保用户只能在 TextFormField Flutter 中输入 1 - 10 的数字 - I want to make sure that users can put numbers only from 1 - 10 in TextFormField Flutter 按下 ElevatedButton 时,我想打开路由应用程序。 Flutter - when on press on ElevatedButton I want open Routing applications. Flutter 我想在 Flutter 中验证我的 textFormField 而不改变装饰 - I want to validate my textFormField in Flutter without changing the decoration 在 Raisedbutton 之后从类中返回一个值 - Returning a value from class in flutter after Raisedbutton
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM