[英]Flutter - how do you update the value of textfield without reopening the widget?
I have multiple TextFormField, all have their own value from a file.我有多个 TextFormField,它们都有自己的文件值。
My problem:我的问题:
-when I change the value of the TextFormField, it changes the value of it's own parameter, but it only changes the other TextFormField(based on the same parameter) when I reopen that page. - 当我更改 TextFormField 的值时,它会更改其自身参数的值,但是当我重新打开该页面时,它只会更改其他 TextFormField(基于相同的参数)。
I tried use setState, but I don't know what parameter should it have.我尝试使用 setState,但我不知道它应该有什么参数。
How should I use setState / what would be a better option?我应该如何使用 setState / 什么是更好的选择? This is how I change the values:
这是我更改值的方式:
onChanged: (value) =>
{ class.data.minimum = int.parse(value),
setState(() {
class.data.minimum=int.parse(value);
})
},
默认情况下,您可以使用ValueKey
文本,但在您的情况下使用globalKey
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.