lengthToRadians function Null safety

num lengthToRadians(
  1. num distance,
  2. [Unit unit = Unit.kilometers]
)

Implementation

num lengthToRadians(num distance, [Unit unit = Unit.kilometers]) {
  num? factor = factors[unit];
  if (factor == null) {
    throw Exception("$unit units is invalid");
  }
  return distance / factor;
}