I have a streamBuilder inside a stateful widget that gets data asynchronously from the server. Additionally, I have a list that collects those data.
StreamBuilder(
stream: myStream.stream,
initialData: initData,
builder: (BuildContext context, AsyncSnapshot snapshot) {
switch(snapshot.connectionState){
case (Connection.active):
setState(() {
data = data + snapshot.data;
});
break;
default:
break;
}
}
)
If I do this, I get the setState() or markNeedBuild() was called during build
.
How do I solve this problem?