convertLength function
Converts a length to the requested unit. Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
Implementation
num convertLength(
num length, [
Unit originalUnit = Unit.kilometers,
Unit finalUnit = Unit.kilometers,
]) {
if (length < 0) {
throw Exception("length must be a positive number");
}
return radiansToLength(lengthToRadians(length, originalUnit), finalUnit);
}