简体   繁体   中英

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM