Flutter - Class 'QuerySnapshot' 没有实例方法 'document'
Flutter - Class 'QuerySnapshot' has no instance method 'document'
我收到以下错误:
════════ 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
是文档 ID。
这段代码returns你是一个列表snapshot.data.documents
不是一个文件
如果你想这样做,你需要尝试这样做
final specificDocument = snapshot.data.documents.where((f) {
return f.documentID == _myMobile;
}).toList();
我收到以下错误:
════════ 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
是文档 ID。
这段代码returns你是一个列表snapshot.data.documents
不是一个文件
如果你想这样做,你需要尝试这样做
final specificDocument = snapshot.data.documents.where((f) {
return f.documentID == _myMobile;
}).toList();