简体   繁体   English

在Flutter中更新StreamController内部的TextFormField

[英]Update a TextFormField inside a StreamController in Flutter

Inside a StreamBuilder, I try to display a TextFormField with a value coming from a REST API. 在StreamBuilder中,我尝试显示一个TextFormField,其值来自REST API。

The stream is triggered and hasData is true 流被触发并且hasData为true

Issue is that the value inside the TextFormField is not updated from the data coming from the stream. 问题是TextFormField内部的值不会从流中获取的数据更新。

I have tested 2 methods: 我已经测试了2种方法:

  • setting initialValue with value coming from the stream 使用来自流的值设置initialValue

  • using a textController (set as a class property) and use .text() 使用textController(设置为类属性)并使用.text()

In both cases, the value is not updated 在两种情况下,该值均不会更新

经过一段时间的测试,它可以与textController解决方案一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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