![](/img/trans.png)
[英]“The method 'getDocuments' isn't defined for the type 'DatabaseReference'.” Flutter - Firebase
[英]The method 'getDocuments' isn't defined for the type 'CollectionReference'
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”。
請你能幫我擺脫這個錯誤嗎?
如果您正在閱讀集合,請使用方法 get() 而不是 getDocuments()。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.