Am creating an app which will display content based on user location. For this am using the Geoflutterfire package to query the data from firestore. The app returns data as desired when I use a single document field .for example
stream = radius.switchMap((rad) {
var collectionReference = firestore
.collection("content")
.doc("onecontentid")
.collection("allcontents");
return geo.collection(collectionRef: collectionReference).within(
center: center, radius: rad, field: 'position', strictMode: true);
});
However I need to stream all documents from the "allcontents" sub collection and to achieve this tried using collectionGroup like this
stream = radius.switchMap((rad) {
var collectionReference = firestore
.collectionGroup("allcontents");
return geo.collection(collectionRef: collectionReference).within(
center: center, radius: rad, field: 'position', strictMode: true);
});
which does not return any data.
My streambuilder for displaying the data looks like this
StreamBuilder(
stream: stream,
builder: (BuildContext context,
AsyncSnapshot<List<DocumentSnapshot>> snapshots) {
if (snapshots.connectionState == ConnectionState.active &&
snapshots.hasData) {
Do stuff}else {
return Center(child: CircularProgressIndicator());
For the first case(single doc query) it is able to retrieve data(Do stuff) From firestore For the second case(collectionGroup) it only shows the circular progress indicator.