as method
Converts the distance to the given LengthUnit
final int km = distance.as(LengthUnit.Kilometer,
new LatLng(52.518611,13.408056),new LatLng(51.519475,7.46694444));
Implementation
double as(final LengthUnit unit, final LatLng p1, final LatLng p2) {
final dist = _calculator.distance(p1, p2);
// If the distance is NaN or infinite, return 0.0
if(dist.isNaN || dist.isInfinite) {
return 0.0;
}
return _round(LengthUnit.Meter.to(unit, dist));
}