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);
}
}
});
}
init Marker Snap
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);
});
The method 'getDocuments' isn't defined for the type 'CollectionReference'.
Please could you help me to get rid this error?
If you are reading the collection once off use the method get() instead of getDocuments().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With