简体   繁体   English

为什么 vs 代码说方法 '.getDocuments' 和 getter 文档没有分别为类型 Query 和 QuerySnapshot 定义?

[英]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.导入 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() .获取文档的方法在 Flutter 中称为get() ,而不是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我建议为这类事情保留 Firebase 文档,对于这种情况,这将是关于从集合中获取多个文档的部分

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

相关问题 没有为类型“QuerySnapshot”定义吸气剂“文档”<object?> '</object?> - The getter 'documents' isn't defined for the type 'QuerySnapshot<Object?>' Flutter firestore QuerySnapshot 在 Android 中没有 getter“文档”的实例 - Flutter firestore QuerySnapshot has no instance of getter 'documents' in Android flutter firebase querysnapshot: dart代码中不区分大小写的方法 - flutter firebase querysnapshot: case insensitive method in dart code 错误:没有为 class 'Object' 定义 getter 'documents' - Error: The getter 'documents' isn't defined for the class 'Object' 未为类型“QuerySnapshot”定义运算符“[]”<object?> ' 尝试定义运算符 '[]' - Flutter</object?> - The operator '[]' isn't defined for the type 'QuerySnapshot<Object?>' Try defining the operator '[]' - Flutter Flutter/Firebase - 列表<dynamic>没有实例 getter 'documents'</dynamic> - Flutter/Firebase - List<dynamic> has no instance getter 'documents' Flutter:没有为 class '对象'定义 getter 'userId' - Flutter: The getter 'userId' isn't defined for the class 'Object' QuerySnapshot 优化了 firebase - QuerySnapshot was optimized out firebase 初始化未来<querysnapshot>在 setState Flutter</querysnapshot> - initialize Future<QuerySnapshot> in the setState Flutter 如何在 Firestore 的子集合中查询文档? - How to Query for documents in a sub collection in Firestore?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM