Created
November 14, 2021 01:38
-
-
Save gunantosteven/16978d720ecc5668689c39a85f1df782 to your computer and use it in GitHub Desktop.
Combining snapshot firestore flutter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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