Home > Software design >  Why is vs code saying the method '.getDocuments' and the getter documents are not defined
Why is vs code saying the method '.getDocuments' and the getter documents are not defined

Time:12-26

void _getQuestions() async {
    // Query Firestore for questions with the specified tags
    Query query = await _firestore
        .collection('questions')
        .where('tags', arrayContainsAny: widget.tags);
        QuerySnapshot querySnapshot = await query.getDocuments();
    setState(() {
      _questions = querySnapshot.documents;
    });

importing cloud_firestore.dart.

I expected the errors to leave, but they are still around.

CodePudding user response:

The method to get the documents is called get() in Flutter, not getDocuments().

I recommend keeping the Firebase documentation handy for this sort of thing, for this case that'd be the section on getting multiple documents from a collection

  • Related