Closed Xentraxx closed 5 years ago
My bad. I didn't initialized the userpos properly.
My bad. I didn't initialized the userpos properly.
@Xentraxx hi! I faces same problem. Can you explain how to solve it? Thank you!
@RakhimyanTim Hey! Sorry but I'm not quite sure what I did wrong anymore. But this is the working initialization of the users position:
Position userpos = await Geolocator().getCurrentPosition();
geo.GeoFirePoint myLocation = geo.Geoflutterfire().point(latitude: userpos.latitude, longitude: userpos.longitude);
Now you can use myLocation as the center in the .within() method. I hope that helps.
Note that Geolocator is another package I use. You can find it on pub.dev
@Xentraxx Thank you! But I can't another package of Geolocator. Can u share pls?
@RakhimyanTim https://pub.dev/packages/geolocator
@Xentraxx Thank you a lot! Solved! But found of another bug - radius is not working(
@RakhimyanTim Radius has to get a widget of the type radius if I remember correctly. Could you explain your problem in more detail?
I wrote the following function:
Stream<List> getListOfHangoutsAround() {
GeoFirePoint myLocation;
Geolocator().getLastKnownPosition().then((userpos) => {
myLocation = Geoflutterfire()
.point(longitude: userpos.longitude, latitude: userpos.latitude)
});
Query collectionReference = Firestore()
.collection('hangouts')
.where('IsActive', isEqualTo: true)
.limit(10);
double radius = 15; //Radius in km
Stream<List> stream = Geoflutterfire()
.collection(collectionRef: collectionReference)
.within(
center: myLocation,
radius: radius,
field: 'GeoLocation',
strictMode: true);
return stream; }
When I debug, the
GeoFirePoint myLocation
is sucessfully initilized and has a geohash. As soon as the App is running the.within()
method, it throws the exception "NoSuchMethodError (NoSuchMethodError: The getter 'hash' was called on null. Receiver: null Tried calling: hash)".What am I missing/doing wrong?
Thanks in advance!