Skip to content

Instantly share code, notes, and snippets.

@gunantosteven
Created November 14, 2021 01:38
Show Gist options
  • Save gunantosteven/16978d720ecc5668689c39a85f1df782 to your computer and use it in GitHub Desktop.
Save gunantosteven/16978d720ecc5668689c39a85f1df782 to your computer and use it in GitHub Desktop.
Combining snapshot firestore flutter
import 'package:async/async.dart';
final Stream<QuerySnapshot> stream0 = collectionReference
.snapshots();
final Stream<QuerySnapshot> stream1 = collectionReference
.snapshots();
return StreamZip([stream0, stream1]).asBroadcastStream();
body: FutureBuilder<Stream<List<QuerySnapshot<Object>>>>(
future: _repository.getSnapshot(),
builder: (BuildContext context,
AsyncSnapshot<Stream<List<QuerySnapshot<Object>>>> snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.done:
return StreamBuilder<List<QuerySnapshot>>(
stream: snapshot.data,
builder: (BuildContext context,
AsyncSnapshot<List<QuerySnapshot>> snapshot) {
final List<QuerySnapshot> querySnapshotData =
snapshot.data.toList();
for (final data in querySnapshotData) {
// you can access your snapshot here...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment