在StreamBuilder中检索子集合(Flutter) [英] Retrieve Subcollection in StreamBuilder (Flutter)

查看:104
本文介绍了在StreamBuilder中检索子集合(Flutter)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Flutter应用程序中有一个StreamBuilder,可用于检索文档中的数据:

I have a StreamBuilder in my Flutter app which I can use to retrieve data in a document:

class Example extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
  ListView.builder(
  itemCount: aCollection.length,
  itemBuilder: (BuildContext context, int index) {
  return Card(
    child: Row(
      children: <Widget>[
         Text(aCollection[index].data['area']), // Return Area

如何检索子集合中的数据?类似于以下内容:

How can I retrieve data in a Subcollection? Something along the lines of:

aCollection[index]['aDoc']**[aSubCollection]**.data['field']

我不确定语法是否正确-如果有人可以将我指向正确的方向,那就太好了!

I'm not sure of the correct syntax - would be great if someone can point me in the right direction!

数据库示例屏幕快照:

Database Example Screenshot:

推荐答案

如果aCollection[index] DocumentSnapshot ,则可以使用aCollection[index].reference.collection("aSubCollection")CollectionReference分配给子集合.

If aCollection[index] is a DocumentSnapshot, then you can get a CollectionReference to a subcollection with aCollection[index].reference.collection("aSubCollection").

这篇关于在StreamBuilder中检索子集合(Flutter)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆