我正在尝试从特定集合用户中检索数据,如下面的代码所示,但是当我查询此集合中的用户时,列表视图不显示。换句话说,它只显示一个 CircularProgressIndicator() 表示没有数据可以找到。在我注释掉 where 查询的那一刻,listview 完美呈现。
backgroundColor: MyApp.backgroundColor,
body: StreamBuilder<QuerySnapshot>(
stream: _firestore
.collection('users')
// .where("chapter", isEqualTo: chapter)
.orderBy('count', descending: true)
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData)
return Center(child: CircularProgressIndicator());
return ListView.builder(
itemExtent: 80.0,
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) =>
_buildListItem(context, snapshot.data.documents[index]),
);
},
),
);
我尝试将 Nested StreamBuilders 和 FutureBuilder 与 Streambuilder 结合使用,但这些解决方案都不起作用。对于这样一个关键特性,必须有一个简单的解决方案。
请告诉我如何同时查询和使用 StreamBuilder。