[英]Flutter show saved bookmark from Firestore
I want to show a story from firebase firestore after that story is saved through a click from a bookmark icon.我想在通过点击书签图标保存该故事后,展示来自 firebase firestore 的故事。
IconButton(
icon: favIcon,
onPressed: () {
setState(
() async {
if (widget.story.favorite.contains(user.uid)) {
widget.story.favorite.remove(user.uid);
} else {
widget.story.favorite.add(user.uid);
await StoryService().updatestory(widget.story);
// await _storyReference
// .doc(widget.story.id)
// .update(widget.story.toMap());
}
},
);
},
),
This is the method that I use to display the story.这是我用来展示故事的方法。
Column(
children: story
.where((favorite) => story.contains(_user!.uid))
.map((StoryModel story) {
return StoriesBookmark(story);
}).toList(),
),
But that is not return anything nor display an error.但这不会返回任何内容,也不会显示错误。 Just white screen and no error at the codes.只是白屏,代码没有错误。
Does anybody know how am I supposed to do?有人知道我该怎么办吗? and is that a good way to retrieve data from the database?这是从数据库中检索数据的好方法吗?
Try using docs instead of doc尝试使用文档而不是文档
Column(
children: snapshot.data.docs.map<Widget>(
(e) => ItemCard(
e.data()['name'],
e.data()['author'],
e.data()['rating'],
e.data()['storytext'],
e.data()['imageUrl'],
),
)
.toList(),
I hope this works!我希望这有效!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.