to method

double to(
  1. LengthUnit unit,
  2. double value
)

Implementation

double to(final LengthUnit unit, final double value) {
  if (unit.scaleFactor == scaleFactor) {
    return value;
  }

  // Convert to primary unit.
  final primaryValue = value / scaleFactor;

  // Convert to destination unit.
  return primaryValue * unit.scaleFactor;
}