Firebase 仅当集合1中的数据与集合2中的数据匹配时填充
我有两个收藏。 第一个系列是这样设置的Firebase 仅当集合1中的数据与集合2中的数据匹配时填充,firebase,flutter,google-cloud-firestore,Firebase,Flutter,Google Cloud Firestore,我有两个收藏。 第一个系列是这样设置的 firestore: SeriesCollection { seriesName: "Test Name" seriesStartDate: seriesImage: } 第二集 firestore: SeriesAudioFiles { series: "Test Name" audioFiles: speaker: dateOfEvent: } 这是我的密码 ExpandableContainer( expanded
firestore: SeriesCollection
{
seriesName: "Test Name"
seriesStartDate:
seriesImage:
}
第二集
firestore: SeriesAudioFiles
{
series: "Test Name"
audioFiles:
speaker:
dateOfEvent:
}
这是我的密码
ExpandableContainer(
expanded: expandFlag,
child: ListView.builder(
itemCount: snapshots.length,
itemBuilder: (context, index) {
if (snapshots[index].data["series"] ==
snapshot[widget.index].data["seriesName"]) {
return ListTile(
leading: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
snapshots[index].data["month"],
style: TextStyle(
color: Colors.black.withOpacity(.5),
fontSize: 15),
),
Text(
snapshots[index].data["day"],
style: TextStyle(
color: Colors.black.withOpacity(0.5),
fontSize: 30),
),
],
),
title: Text(snapshots[index].data["sermonTitle"]),
subtitle:
Text(snapshots[index].data["sermonReference"]),
trailing: Icon(Icons.arrow_forward_ios),
onTap: () => passData(snapshots[index]),
);
}
},
),)
ExpandableContainer(
扩展:expandFlag,
子项:ListView.builder(
itemCount:snapshots.length,
itemBuilder:(上下文,索引){
if(快照[索引].数据[“系列”]==
快照[widget.index]。数据[“seriesName”]){
返回列表块(
前导:列(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
正文(
快照[索引]。数据[“月”],
样式:TextStyle(
颜色:颜色。黑色。不透明度(.5),
尺寸:15),,
),
正文(
快照[索引]。数据[“天”],
样式:TextStyle(
颜色:颜色。黑色。不透明度(0.5),
尺寸:30),,
),
],
),
标题:文本(快照[索引].数据[“sermonTitle”]),
字幕:
文本(快照[索引].数据[“sermonReference”]),
尾随:图标(图标。箭头\前进\ ios),
onTap:()=>passData(快照[索引]),
);
}
},
),)
我试图做的是仅当序列与两个集合中的序列名称匹配时才列出序列音频文件
我可能把firestore的数据设置错了,但我对这方面很陌生
我尝试过使用IF-contains,但似乎无法让它填充我实际需要的数据
当我能够获得实际有效的数据时,它是通过一个循环多次将项目拉入的。您可以轻松使用收集的
.where()
方法。这样,您就可以建立一个仅包含所需音频的列表:
audioListFromSerie = audioCollection.where((i) => i.series == serieList[iterationIndex].seriesName).toList();
如果您在编写代码时遇到问题,请编辑您的问题以包括。我已添加了我的代码。很抱歉