Currently I have a StreamBuilder pulling data from Firebase for a group messaging app. I have a snapshot.hasData check to make sure that there is data before displaying the messages. The problem is that when setState rebuilds the widgets, it also rebuilds the StreamBuilder causing it to display the static snapshot.hasData == false content before it finishes loading the data again. This looks really bad because it loads so fast that it just looks like the screen is flickering for a second every rebuild.
How would I go about retaining the data while it reloads itself, so it does not appear to flicker?
Is there a way I can prevent the StreamBuilder from rebuilding given specific circumstances?
Thanks!
Edit added current code.
var firebaseStream;
@override
void initState() {
super.initState();
firebaseStream = Firestore.instance
.collection('groups')
.document(groupID)
.collection('messages')
.orderBy('date', descending: true)
.limit(15)
.snapshots();
StreamBuilder(
stream: firebaseStream,
builder: (context, snapshot) {
if (!snapshot.hasData)
return Container(
color: Colors.red,);
return ListView.builder(