combineLatest2 with only the first non-null stream outputs


I have two streams coming from firestore and I need to do a computationally intensive operation only the first time these two streams produce values.

I’ve considered combineLatest2(), but as far as I can tell this will execute every time the streams produce output (not just the first time).

I’ve considered .firstWhere(), but I can’t figure out how to combine the streams to use this.

Any suggestions would be appreciated.



Your responses helped me get to a useful solution.

combineLatest2(stream1.take(1), stream2.take(1), (s1, s2) {
// computationally intensive operation
}).listen((_) => {});

Answered By – Simpler

Answer Checked By – Marie Seifert (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.