find static method

Unit find(
  1. String name
)

Find a predefined unit by its name.

 double mbMultiplier = Unit.find('megabyte').multiplier;

While this function is provided, you should, if possible, refer directly to the wanted unit.

name is the name field of the requested unit. Throws ArgumentError if the requested unit is not found.

Implementation

static Unit find(String name) {
  var unit = _byName[name];

  if (unit == null) {
    throw ArgumentError.value(name, 'name',
        'Expected name to be one of ${_byName.keys.join(', ')}.');
  }

  return unit;
}