【发布时间】:2019-05-31 22:49:20
【问题描述】:
我正在使用StreamBuilder 来监听 TextField 的更改并相应地更新 TextField errorText。但是现在我也想通过快照数据给 TextField 设置一些文本。但是打字时光标根本不动。以下是我的代码:
Widget goalField() {
return StreamBuilder(
stream: _bloc.goalMessage,
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
return TextField(
controller: TextEditingController(text: snapshot.data),
keyboardType: TextInputType.multiline,
maxLines: 3,
onChanged: _bloc.changeGoalMessage,
decoration: InputDecoration(
hintText: "Enter your goal here", errorText: snapshot.error),
);
});
}
它在一个循环中进行。我该如何解决这个问题?
【问题讨论】:
-
感谢它的工作@anmol.majhail
标签: flutter