Unit class abstract

Representation of a physical unit, including its underlying Dimensions and a scale factor relative to the SI-MKS base units.

All Units are immutable and can be used as compile-time constants.

Units, like Dimensions, support natural arithmetic operations including multiplication, division and exponentiation. Thus new Units can be created from existing Units.

Implementers

Constructors

Unit({num scale = 1, required Dimensions dimensions, required String symbol, required String singular, required String plural, bool spaceBeforeSymbol = true})
Creates a new unit with the given dimensions, scale, symbol, singular and plural names.
const

Properties

dimensions Dimensions
The dimensions of the unit, e.g. length, time, mass.
final
hashCode int
The hash code for this object.
no setteroverride
plural String
The plural name of the unit, e.g. "metres", "seconds".
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
safePlural String
The plural name of the unit, wrapped in square brackets if it is not a NamedUnit.
no setter
safeSingular String
The singular name of the unit, wrapped in square brackets if it is not a NamedUnit.
no setter
safeSymbol String
The symbol of the unit, wrapped in square brackets if it is not a NamedUnit.
no setter
scale num
The ratio of the unit to the base unit in SI-MKS.
final
singular String
The singular name of the unit, e.g. "metre", "second".
final
spaceBeforeSymbol bool
Whether to put a space before the symbol when displaying it.
final
symbol String
The symbol of the unit, e.g. "m" for metre, "s" for second.
final
symbolForQuantity String
The symbol of the unit, or an empty string if the unit is the dimensionless unit "one".
no setter
symbolWithSpace String
The symbol of the unit, potentially prepended with a space based on spaceBeforeSymbol.
no setter

Methods

cubed() DerivedUnit
A cubed DerivedUnit copy of this unit.
inverse() Unit
An inverted copy of this unit, inverting both the dimensions and scale.
nameForValue(num value) String
The appropriate name of the unit for the given value, either singular or plural.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
squared() DerivedUnit
A squared DerivedUnit copy of this unit.
toString() String
A string representation of this object.
override

Operators

operator *(Unit other) Unit
Multiplies this unit by other, creating a new DerivedUnit.
operator /(Unit other) Unit
Divides this unit by other, creating a new DerivedUnit.
operator ==(Object other) bool
Whether this unit is equal to other, having the same scale and dimensions.
override
operator ^(num exponent) Unit
Raises this unit to the power of exponent, creating a new DerivedUnit.

Constants

one → const Unit
The dimensionless base unit "one".