Flutter-类'QuerySnapshot'没有实例方法'document'

时间:2019-12-19 08:24:03

标签: flutter snapshot stream-builder

我遇到以下错误:

  

════════小部件库捕获到异常   ══════════════════════════════════════════════════ ═════

     

以下NoSuchMethodError被抛出   StreamBuilder(脏,状态:   _StreamBuilderBaseState>#f469b):类“ QuerySnapshot”没有   实例方法“文档”。接收方:“ QuerySnapshot”的实例   尝试调用:document(“ + 918130343322”)

new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='blenderFive yellow']//span[normalize-space()='Bathroom']//preceding::input[1]"))).click();

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"]),); 是文档ID。

1 个答案:

答案 0 :(得分:0)

此代码为您返回列表snapshot.data.documents而不是文档

如果要执行此操作,请尝试执行此操作

final specificDocument = snapshot.data.documents.where((f) {
     return f.documentID == _myMobile;
}).toList();