assertUnit method Null safety

void assertUnit(
  1. String unit,
  2. [String? name]
)

Throws a SassScriptException unless this has unit as its only unit (and as a numerator).

If this came from a function argument, name is the argument name (without the $). It's used for error reporting.

Implementation

void assertUnit(String unit, [String? name]) {
  if (hasUnit(unit)) return;
  throw _exception('Expected $this to have unit "$unit".', name);
}