While using geoFlutter fire to get the location nearby me. Some error is occurring. The error is
E/flutter ( 3409): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: NoSuchMethodError: The getter 'hash' was called on null.
E/flutter ( 3409): Receiver: null
E/flutter ( 3409): Tried calling: hash
The function I'm calling is here
void nearbyLocations() async {
var collectionRef = FirebaseFirestore.instance.collection('locations');
double radius = 10;
String field = 'position';
GeoFirePoint center = await getCurrentLocation();
Stream<List<DocumentSnapshot>> stream = geo
.collection(collectionRef: collectionRef)
.within(center: center, radius: radius, field: field, strictMode: true);
stream.listen((List<DocumentSnapshot> documentList) {
if (documentList.length > 0) {
print(documentList.length);
for (int i = 0; i < documentList.length; i++) {
GeoPoint pos = documentList[i].data()['position']['geopoint'];
print(documentList[i].data());
print(center.distance(lat: pos.latitude, lng: pos.longitude));
}
} else {
print('Nothing');
}
});
}
The above code is place in a file called geoLocator.dart and in a class called GeoLocator and It's called in another dart file like this GeoLocator().nearbyLocations();
On Analysis the error is occurring in this line Stream<List<DocumentSnapshot>> stream = geo.collection(collectionRef: collectionRef).within(center: center,radius: radius, field: field, strictMode: true);