In a flutter project, I am trying to return a list of objects as stream from a method. Here is my code:
Stream<List<Flight>> getLove(String seamanId) async* {
yield* _firestore
.collectionGroup(ConstStrings.seamans)
.where(ConstStrings.uid, isEqualTo: seamanId)
.limit(1)
.snapshots()
.map((querySnapshot) {
final docref = querySnapshot.docs[0].reference;
return docref.collection(ConstStrings.flights).snapshots().map(
(snapshot) => (snapshot.docs
.map((doc) => FlightDto.fromFirestore(doc).toDomain())
.toList()),
);
});
}
But getting the following compilation error :
The return type 'Stream<List<Flight>>' isn't a 'List<Flight>'
How to solve this?