getDistance static method
Implementation
static String getDistance(String currLocation, String otherLocation) {
try {
List<String> currCoordinates = currLocation.split("_");
List<String> otherCoordinates = otherLocation.split("_");
final startCoordinate = new haversine.Location(
double.parse(currCoordinates[0]), double.parse(currCoordinates[1]));
final endCoordinate = new haversine.Location(
double.parse(otherCoordinates[0]), double.parse(otherCoordinates[1]));
final haversineDistance = haversine.HaversineDistance();
final distanceInKiloMeter = haversineDistance.haversine(
startCoordinate, endCoordinate, haversine.Unit.KM);
return distanceInKiloMeter.toStringAsFixed(2);
} on Exception catch (e) {
print(e.toString());
return "0";
}
}