StreamProvider works correctly, however on stream update child widgets don't rebuild. UI not updating

烈酒焚心 提交于 2020-06-17 15:11:45

问题


I'm using a StreamProvider in flutter to listen to my firebase collection. The stream works correctly however since I'm passing down the value of the stream provider to other child widgets(all of which are stateless) the child widgets don't rebuild even though the stream is correctly updated.

This is my stream provider

StreamProvider<List>.value(
  value: ChatService(shadeUID: widget.poll.shadeUID, pollUID: widget.poll.uid).threads,
  child: ThreadsList(poll: widget.poll, shadowUID: widget.shadowUID),
  // ignore: missing_return
  catchError: (_, err) {
   print(err.toString());
  },
)

I'm accessing the stream provider in the widget ThreadsList() using

final threadList = Provider.of<List>(context);

ThreadsList() is a stateless widget. The threadlist is passed down to another stateless widget which needs to update on change. However the value of threadlist inside the child widget remains the same even though the provider final threadList = Provider.of<List>(context);updates.

来源:https://stackoverflow.com/questions/62270476/streamprovider-works-correctly-however-on-stream-update-child-widgets-dont-reb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!