【发布时间】:2021-03-10 21:53:42
【问题描述】:
我有一个名为UserCollection 的集合,
在这个集合中,我有一个包含其他特定文档的子集合,称为 'UserSubCollection'
使用 StreamBuilder 我试图获取这些集合失败
StreamBuilder(
stream: FirebaseFirestore.instance
.collection('UserCollection')
.doc(firebaseUser.uid).collection('UserSubCollection')
.snapshots(),
builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError)
return Center(child: Text("Error"));
else if (snapshot.data.docs.isEmpty) //also check if empty! show loader?
return Center(child: Text('Errors'));
else
return new ListView.builder(
itemCount: snapshot.data.docs.length,
itemBuilder: (BuildContext context, int index) {
我只能得到一个或一个集合或子集合。 有没有办法同时获得它们?
【问题讨论】:
标签: flutter google-cloud-firestore