Reputation: 3
I am getting the following error:
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following NoSuchMethodError was thrown building StreamBuilder(dirty, state: _StreamBuilderBaseState>#f469b): Class 'QuerySnapshot' has no instance method 'document'. Receiver: Instance of 'QuerySnapshot' Tried calling: document("+918130343322")
body:
StreamBuilder(
stream: Firestore.instance.collection('users').snapshots(),
builder: (context, snapshot){
if(!snapshot.hasData) return Text('Loading data.....');
return
Center(child: Text(snapshot.data.document(_myMobile)["Name"]),);
_mymobile
is the document ID.
Upvotes: 0
Views: 5568
Reputation: 3451
this code returns you a list snapshot.data.documents
not a document
if you want to do this you need try do this
final specificDocument = snapshot.data.documents.where((f) {
return f.documentID == _myMobile;
}).toList();
Upvotes: 1