I'm using firebase and I have this:
Stream<QuerySnapshot> qs = FirebaseFirestore.instance
.collection("$mypath")
.orderBy(order)
.limit(10)
.startAfterDocument(lastDoc)
.snapshots();
When I pass qs
to a StreamBuilder, the returned snapshot can do snapshot.hasError
.
StreamBuilder(
stream: qs,
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError) ... // hasError works
},
)
However when I listen to the stream, things like hasError, hasData ..., are not recognized anymore
qs.listen((event) {
if (event.hasError) // error: The getter 'hasError' isn't defined for the type 'QuerySnapshot<Object?>'.
});
I still can do event.docs
and I get the data successfully, but I can't listen for errors. Am I doing something wrong?