SassNumber.withUnits constructor Null safety

SassNumber.withUnits(
  1. num value,
  2. {List<String>? numeratorUnits,
  3. List<String>? denominatorUnits}
)

Creates a number with full numeratorUnits and denominatorUnits.

Implementation

factory SassNumber.withUnits(num value,
    {List<String>? numeratorUnits, List<String>? denominatorUnits}) {
  if (denominatorUnits == null || denominatorUnits.isEmpty) {
    if (numeratorUnits == null || numeratorUnits.isEmpty) {
      return UnitlessSassNumber(value);
    } else if (numeratorUnits.length == 1) {
      return SingleUnitSassNumber(value, numeratorUnits[0]);
    } else {
      return ComplexSassNumber(
          value, List.unmodifiable(numeratorUnits), const []);
    }
  } else {
    return ComplexSassNumber(
        value,
        numeratorUnits == null || numeratorUnits.isEmpty
            ? const []
            : List.unmodifiable(numeratorUnits),
        List.unmodifiable(denominatorUnits));
  }
}