【发布时间】:2020-12-05 13:37:11
【问题描述】:
我从 Firebase 获取数据,我不想获取 create_uid 与 uid 相同的元素。所以问题是如何在地图上运行迭代时跳过一些元素。
// list from snapshot
List<ImageProperty> _pictureListFromSnapShot(QuerySnapshot snapshot) {
return snapshot.documents.map((doc) {
return ImageProperty(
title: doc.data['title'] ?? null,
filename: doc.data['filename'] ?? null,
token: doc.data['token'] ?? null,
filelocation: doc.data['filelocation'] ?? null,
url: doc.data['url'] ?? null,
created: doc.data['created'] ?? null,
creator_uid: doc.data['creator_uid'] ?? null,
format: doc.data['format'] ?? null,
created_date: doc.data['created_date'].toString() ?? null,
timestamp: doc.data['timestamp'] ?? null,
tag_label: doc.data['tag_label'] ?? null,
user_tag: doc.data['user_tag'] ?? null,
rating: doc.data['rating'] ?? 0,
score: doc.data['score'] ?? 0,
display_count: doc.data['score_display_count'] ?? 0,
judges: doc.data['judges'] ?? null,
isClicked: false,
isShown: false,
);
}).toList();
}
// get test stream
Stream<List<ImageProperty>> get pictureData {
return pictureCollection.snapshots().map(_pictureListFromSnapShot);
}
请帮助我。谢谢你。我期待您的来信。
【问题讨论】:
标签: dictionary flutter dart iterator snapshot