简体   繁体   English

Firebase 快照文档。 我正在关注教程,但我不知道如何进行此更改

[英]Firebase snapshot documentations. I am following a tutorial but i can't figure out how to make this change

 Widget build(BuildContext context) {
return Scaffold(
  backgroundColor: Colors.orange,
  appBar: header(context, titleText: "Activity Feed"),
  body: Container(
    child: FutureBuilder(
      future: getActivityFeed(),
      builder: (context, snapshot) {
        if (!snapshot.hasData) {
          return circularProgress();
        }
        return ListView(
          children: snapshot.data!.docs, // i am getting an error here
        );
      },
    ),
  ),
);

} } } }

2nd error case:第二个错误案例:

User user = User.fromDocument(snapshot.data()); // i am getting error here

3rd case: `第三种情况:`

 List<UserResult> userResults = [];
    snapshot.data!.docs.forEach((doc) {
      User user = User.fromDocument(doc);
      final bool isAuthUser = currentUser.id == user.id;
      final bool isFollowingUser = followingList.contains(user.id);
      // remove auth user from recommended list
      if (isAuthUser) {
        return;
      } else if (isFollowingUser) {
        return;
      } else {
        UserResult userResult = UserResult(user);
        userResults.add(userResult);
      }
    });

Here on snapshot i am getting error in every scenario.在快照上,我在每种情况下都遇到错误。 I don't understand how to change the snapshot formation i should do enter image description here我不明白如何更改快照格式我应该在此处输入图像描述

instead of .documents try .doc .而不是.documents尝试.doc

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我不知道为什么我收到以下错误“错误:元素类型无效:” - I can't figure out why I am getting the following error "Error: Element type is invalid:" 我正在使用以下代码在Firebase上保存数据。但是数据没有保存在Firebase中,我该如何解决? - I am using following code to save data on firebase .but data dont save in firebase , how can I fix it? 无法弄清楚如何在 firebase 中编写正确的安全规则 - Can't figure out how to write proper security rules in firebase 我尝试为 createUser 创建一个可调用的函数,但是我在运行它时遇到了一个错误,我不知道为什么 - I tried making a callable function for createUser but I am getting an error wen I run it and I can't figure out why 我是 firebase 的新人,我正在尝试获取父集合的 ID 文档,但我无法弄清楚 - I'm new in firebase and I'm trying to get id document for parent collection but I can't figure it out 如何在Swift 4中映射我的Firebase快照? - How can I map my Firebase snapshot in Swift 4? 如何在Swift中将Firebase数据库快照转换为数组列表? - How can I convert a Firebase Database Snapshot into an Array List in Swift? 如何获取 firebase 集合的文档快照? - How can I get a document snapshot of firebase collection? 在遵循 Flutter Firebase 教程时,我在 dart 中收到未为对象错误定义的 [] 错误? - I'm getting an [] isn't defined for Object error in dart when following a Flutter Firebase tutorial? 如何按顺序获取Firebase快照中的子级列表? - How can I get a list of children in a Firebase snapshot in order?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM