I am developing the nearest Food Dish application location. I managed to display it based on the location closest to the user, using this plugin great_circle_distance
I want to know how to set the max radius? ex. < 30 Km
Here my code:
_foodByCategories.sort((a, b) {
var distance1 = new GreatCircleDistance.fromDegrees(
latitude1:
model.userLocation == null ? 0.0 : model.userLocation["latitude"],
longitude1: model.userLocation == null
? 0.0
: model.userLocation["longitude"],
latitude2: a.lat,
longitude2: a.long);
double totaldistance1 = distance1.haversineDistance();
var distance2 = new GreatCircleDistance.fromDegrees(
latitude1:
model.userLocation == null ? 0.0 : model.userLocation["latitude"],
longitude1: model.userLocation == null
? 0.0
: model.userLocation["longitude"],
latitude2: b.lat,
longitude2: b.long);
double totaldistance2 = distance2.haversineDistance();
return (totaldistance1 - totaldistance2).toInt();
});
Any answer will appreciated.