I’m trying to fetch data using firestore stream on flutter application, however, this query randomly hangs and never come back
Here is how I’m trying to read:
await for (QuerySnapshot e in query.snapshots()) {
print('here ---');
List<Package> packagesList = [];
for (var doc in e.docs) {
var data = doc.data() as Map<String, dynamic>;
Package package = Package.fromDocument(data);
if (filterFunction != null) {
if (!filterFunction(package)) {
continue;
}
}
packagesList.add(package);
}
print('done');
yield packagesList;
The query sometimes work and sometimes does not, the print(‘here —‘) sometime got printed and other does not at all. hence, the for(…) does not finish and print(‘done’) is not printed no matter how much I wait.
I’m using the latest versions of flutter and firebase packages of all (firebase core and cloud firestore).
Thanks in advance