GeoFlutterFire icon indicating copy to clipboard operation
GeoFlutterFire copied to clipboard

Will this plugin get the same "closest" filter, like GeoFireX?

Open joknjokn opened this issue 5 years ago • 1 comments

Hi,

I saw that GeoFireX has a closest() option, which sounds like a great substitute for limit().

Will this plugin support closest() at some point?

Thanks, Jonas

(source, described here: https://fireship.io/lessons/geolocation-query-in-firestore-realtime/ )

joknjokn avatar Feb 24 '20 13:02 joknjokn

The closest is in the position 0 of the DocumentSnapshot list.

Query ref = FirebaseFirestore.instance
.collection('SomeCollection');

GeoFirePoint center = geo.point(latitude: latitude, longitude: longitude);

subscription = radius.switchMap((rad) {
  return geo.collection(collectionRef: ref).within(
      center: center, radius: rad, field: 'position', strictMode: true);
}).listen((List<DocumentSnapshot> documentList) {
  print(documentList[0]); //this one is the closest
});
}

saulvh avatar Apr 12 '21 21:04 saulvh