distanceBetween static method

double distanceBetween(
  1. double startLat,
  2. double startLon,
  3. double endLat,
  4. double endLon,
)

Calculate the distance between origin and destination.

Implementation

static double distanceBetween(
  double startLat,
  double startLon,
  double endLat,
  double endLon,
) {
  final dLat = _toRadians(endLat - startLat);
  final dLon = _toRadians(endLon - startLon);

  final a = pow(sin(dLat / 2), 2) +
      pow(sin(dLon / 2), 2) *
          cos(_toRadians(startLat)) *
          cos(_toRadians(endLat));
  final c = 2 * asin(sqrt(a));

  return 6378137.0 * c;
}