I found this website How to run a geo "nearby" query with firestore? for find nearby location from my current location when try write swift code to dart like in below it does not retrieve data, please till me what the problem ?
void getDocumentNearBy( double latitude, double longitude , double distance) {
~1 mile of lat and lon in degrees
var lat = 0.0144927536231884;
var lon = 0.0181818181818182;
var lowerLat = latitude - (lat * distance);
var lowerLon = longitude - (lon * distance);
var greaterLat = latitude + (lat * distance);
var greaterLon = longitude + (lon * distance);
var lesserGeopoint = GeoPoint(lowerLat, lowerLon);
var greaterGeopoint = GeoPoint(greaterLat, greaterLon);
var docRef = firestore.collection("Coupons");
var query = docRef.where("Coupons", isGreaterThan: lesserGeopoint).where("Coupons", isLessThan: greaterGeopoint);
query.snapshots();
builder: (BuildContext context,
AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasData) {
print(query);
}else {
print("there is an error");
}
};
void run() {
Get all locations within 10 miles of Google Headquarters
getDocumentNearBy(37.422000, -122.084057,10);
}