【问题标题】:The method 'getDocuments' isn't defined for the type 'CollectionReference'没有为“CollectionReference”类型定义方法“getDocuments”
【发布时间】:2021-06-11 19:55:10
【问题描述】:
   FirebaseFirestore.instance.collection('locations').getDocuments().then((docs){
      if(docs.documents.isNotEmpty){
        for(int i=0 ;i<docs.documents.length;i++){
            initMarker(docs.documents[i].data , docs.documents[i].documentID);
        }
      }
    });
  }

初始化标记捕捉

void initMarker(request,requestId){
  var markerIdVal = requestId;
  final MarkerId markerId = MarkerId(markerIdVal);
  //creating a new Marker
  final Marker marker = Marker(
    markerId:markerId,
    position:LatLng(request['loc_Coords'].lattitude,request['loc_Coords'].longitude),
    infoWindow:InfoWindow(
      title:request['loc_Name'],
      snippet:request['loc_Description'],
    ),
    );
  setState((){
    markers[markerId] = marker;
    print(markerId);
  });

没有为类型“CollectionReference”定义方法“getDocuments”。

请你帮我摆脱这个错误?

【问题讨论】:

    标签: flutter google-cloud-firestore


    【解决方案1】:

    如果您正在阅读集合,请使用方法 get() 而不是 getDocuments()。

    【讨论】:

    • FirebaseFirestore.instance.collection('locations').get().then((result){//code});
    猜你喜欢
    • 2021-05-12
    • 2023-03-03
    • 2021-09-02
    • 2022-11-21
    • 2021-10-19
    • 2020-12-14
    • 2021-07-19
    • 2021-09-01
    • 2021-09-17
    相关资源
    最近更新 更多