Reputation: 294
How to show list of users in FireStore(Firebase Database) Based only in verified Fild ! So if there is non-verified so will not list them in streambuilder, Here my example but I got errors !
Widget verified (){
return FutureBuilder(
future: Firestore.instance.collection('users').where('verified ',isEqualTo: 'true').getDocuments(),
builder: (context, data){
return ListView(
children: <Widget>[
Text('${data.data['verified '].toString()}'),
],
);
},
);
}
The Error is :
Class 'QuerySnapshot' has no instance method '[]'.
Receiver: Instance of 'QuerySnapshot'
Tried calling: []("verified ")
Upvotes: 0
Views: 212
Reputation: 5172
I generally use stream builder for firestore u can use like that :
return StreamBuilder(
stream: Firestore.instance
.collection('users')
.where('verified ', isEqualTo: 'true')
.snapshots(),
builder: (context, data) {
if (data.hasData) {
return ListView(
children: <Widget>[
Text('${data.data['verified '].toString()}'),
],
);
}
return Center(
child: CircularProgressIndicator(),
);
},
);
If u want to use future builder then u have to check for did we got data or not
return FutureBuilder(
future: Firestore.instance
.collection('users')
.where('verified ', isEqualTo: 'true')
.getDocuments(),
builder: (context, data) {
if (data.data != null) { //data.connectionState == ConnectionState.done
return ListView(
children: <Widget>[
Text('${data.data['verified '].toString()}'),
],
);
}
return CircularProgressIndicator();
},
);
Upvotes: 1