firebase - 如何在flutter firebase中使用子集合填充扩展列表视图
问题描述
我在颤振中有一个类别页面,其中有一个带有类别名称的可扩展磁贴,每个类别都有多个子类别。我的firebase设置如下
我的代码如下
Container(
padding: EdgeInsets.all(10.0),
child: FutureBuilder(
future: getcat(),
builder: (context, AsyncSnapshot<QuerySnapshot> snapshot){
if (snapshot.connectionState == ConnectionState.done){
return ListView.builder(
shrinkWrap: true,
itemCount: snapshot.data.docs.length,
itemBuilder: (BuildContext context, int index){
return ExpansionTile(
title: Text(snapshot.data.docs[index].data()["Name"]),
children: [
//List View nested
FutureBuilder(future: getcat(),
builder: (context, AsyncSnapshot<QuerySnapshot> snapshot){
if (snapshot.connectionState == ConnectionState.done){
return ListView.builder(
shrinkWrap: true,
itemCount: snapshot.data.docs.length,
itemBuilder: (BuildContext context, int index){
return ListTile(
title: Text(snapshot.data.docs[index].data()["Name"]),
);
}
);
}else if(snapshot.connectionState == ConnectionState.none){
return Text("No data");
}
return CircularProgressIndicator();
}
)
],
);
}
);
}else if(snapshot.connectionState == ConnectionState.none){
return Text("No data");
}
return CircularProgressIndicator();
},
),
),
);
}
}
Future<QuerySnapshot> getcat() {
return fb.collection("Categories").get();
}
如何在扩展磁贴的子项列表中获取所有子集合名称的列表
解决方案
推荐阅读
- python - 在 Sphinx/Jinja 中使用标签/关键字创建一个页面,其中包含指向包含所述标签/关键字的所有其他页面的链接列表
- php - 为什么我不能从文档根目录之外投射由 PHP 提供的 MP4 文件?
- php - 配置 Apache 以接受任何主机请求
- r - 如何使用 R 创建时间序列螺旋图
- botframework - 如何从瀑布中的 TextPrompt 获得 Luis 得分最高的意图(Bot Framework v4)
- android - 如何杀死其他进程或在应用程序中使用 adb 命令行
- compiler-construction - Bison 意外令牌导致语法错误
- javascript - 选择选项的自定义属性并从 Angular 5 中的 AbstractControl 访问它?
- c - 在用 C 编写的自定义 shell 程序中重定向 I/O
- ios - 使用 Siesta 发布 API 时,请求方法返回“无法解析服务器响应”错误