问题
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