DarshanGowda0 / GeoFlutterFire

:fire:GeoFlutterFire:fire: is an open-source library that allows you to store and query firestore documents based on their geographic location.
https://youtu.be/MYHVyl-juUk
MIT License
305 stars 261 forks source link

NoSuchMethodError (NoSuchMethodError: The getter 'hash' was called on null. Receiver: null Tried calling: hash) #60

Closed Xentraxx closed 5 years ago

Xentraxx commented 5 years ago

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!

Xentraxx commented 5 years ago

My bad. I didn't initialized the userpos properly.

rakhimian commented 4 years ago

My bad. I didn't initialized the userpos properly.

@Xentraxx hi! I faces same problem. Can you explain how to solve it? Thank you!

Xentraxx commented 4 years ago

@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

rakhimian commented 4 years ago

@Xentraxx Thank you! But I can't another package of Geolocator. Can u share pls?

Xentraxx commented 4 years ago

@RakhimyanTim https://pub.dev/packages/geolocator

rakhimian commented 4 years ago

@Xentraxx Thank you a lot! Solved! But found of another bug - radius is not working(

Xentraxx commented 4 years ago

@RakhimyanTim Radius has to get a widget of the type radius if I remember correctly. Could you explain your problem in more detail?