Quantity constructor

Quantity(
  1. double value, [
  2. Unit unit = Unit.unity
])

Implementation

factory Quantity(double value, [Unit unit = Unit.unity]) {
  if (unit == Unit.unity) {
    return Quantity._(value, unit);
  }

  final simplifiedUnit = unit.simplify();
  return Quantity._(value * simplifiedUnit.factor, simplifiedUnit.unit);
}