isUnitName static method

bool isUnitName(
  1. String? unit
)

Returns if the given string is valid unit name or null.

This method does not check that the unit name is part of the standard unit database.

Implementation

static bool isUnitName(String? unit) {
  if (unit == null) return true;
  if (unit.isEmpty) return false;

  return unit.codeUnits.every(_checkCode);
}