简体   繁体   中英

Why is vs code saying the method '.getDocuments' and the getter documents are not defined for types Query and QuerySnapshot respectively?

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.

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

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