I have the following in my app:
stream: Firestore.instance.collection('stores').document(currentUserUID).snapshots(),
builder: (BuildContext context, AsyncSnapshot<DocumentSnapshot> snapshot) {
if (snapshot.hasData) {
return ListView.builder(
//do some stuff here with the data
} else {
return LoadingAnimation();
}
}
}
}
Pretty standard, but I am getting the error listed above.
I have vertified that currentUserID populates with the correct data before this stream is called.
In testing I have found that this error is perhaps likely caused by the fact that at runtime, "if (snapshot.hasData) {" shows me that there is no data in the snapshot yet. If I do anything at all, like minimise the app and refocus it again, all the data loads. So it simply just needs a redraw.
Is there a way to do an "await" or something on this? There must be a simple fix for this problem, seems to be a simple issue, but I just can't find a solution in any of the other threads about this.
Anyone have any ideas on how I can either do an await on this stream, or force it to update when it receives data (I kinda thought that was the whole point of a stream, but this examples proves that it doesn't do this).