flutter Stream?中的Firestore子集合< QuerySnapshot>

xxe27gdn  于 2023-03-24  发布在  Flutter
关注(0)|答案(1)|浏览(108)

不知道如何做到这一点-我有一个议程项目的集合,并希望做一个子集合,每个议程项目的发言者将举行。但我不知道如何做到这一点?

`class _PanelsGreeceDayOneState extends State<PanelsGreeceDayOne> {
  final Stream<QuerySnapshot> _greecePanelsOne = FirebaseFirestore.instance
      .collection('Greece')
      .where('day', isEqualTo: 'Thursday, 6th April')
      .orderBy('number', descending: false)
      .get()
      .then((QuerySnapshot querySnapshot) => querySnapshot.docs.forEach((doc) {
         FirebaseFirestore.instance
               .doc(doc.id)
               .collection("speakers")
               .get();
           
      }))
      .snapshots();`

这就是我所做的,但它告诉我,方法'snapshots'没有为类型'Future'定义。在我添加speakers子集合之前,它完全按照预期工作,但现在我需要这个添加的功能,我被难住了:(

6tr1vspr

6tr1vspr1#

您使用的.snapshots()不正确。应该如下所示:

`class _PanelsGreeceDayOneState extends State<PanelsGreeceDayOne> {
  final Stream<QuerySnapshot> _greecePanelsOne = FirebaseFirestore.instance
      .collection('Greece')
      .where('day', isEqualTo: 'Thursday, 6th April')
      .orderBy('number', descending: false)
      .snapshots()
      .listen((QuerySnapshot querySnapshot) => querySnapshot.docs.forEach((doc) {
         FirebaseFirestore.instance
               .doc(doc.id)
               .collection("speakers")
               .get();
           
  }));`

相关问题