getUnit method

UcumUnit? getUnit(
  1. String code
)

Implementation

UcumUnit? getUnit(String code) {
  for (final BaseUnit unit in baseUnits) {
    if (unit.code == code) {
      return unit;
    }
  }
  for (final DefinedUnit unit in definedUnits) {
    if (unit.code == code) {
      return unit;
    }
  }
  for (final BaseUnit unit in baseUnits) {
    if (unit.names.contains(code)) {
      return unit;
    }
  }
  for (final DefinedUnit unit in definedUnits) {
    if (unit.names.contains(code)) {
      return unit;
    }
  }
  return null;
}