calculateDistanceBetweenTwoPoints method

double calculateDistanceBetweenTwoPoints({
  1. required double latitude1,
  2. required double longitude1,
  3. required double latitude2,
  4. required double longitude2,
})

To get the distance between the 2 points for latitudes and longitudes

Implementation

double calculateDistanceBetweenTwoPoints({required double latitude1, required double longitude1, required double latitude2, required double longitude2}) {
  var p = 0.017453292519943295;
  var c = cos;
  var a = 0.5 - c((latitude1 - latitude1) * p) / 2 + c(latitude1 * p) * c(latitude1 * p) * (1 - c((longitude2 - longitude1) * p)) / 2;
  return 12742 * asin(sqrt(a));
}