distanceBetween method
Great-circle distance between two coordinates in meters (Haversine).
Implementation
double distanceBetween(
double startLatitude,
double startLongitude,
double endLatitude,
double endLongitude,
) {
const earthRadius = 6378137.0;
final dLat = _radians(endLatitude - startLatitude);
final dLon = _radians(endLongitude - startLongitude);
final a =
math.pow(math.sin(dLat / 2), 2) +
math.pow(math.sin(dLon / 2), 2) *
math.cos(_radians(startLatitude)) *
math.cos(_radians(endLatitude));
return earthRadius * 2 * math.asin(math.sqrt(a));
}