Quantity class
Measures a number of discrete items.
Technically not a measurement, and somewhat controversial for its inclusion in the SI base units, this is nonetheless a useful measurement for counting items. This class allows conversions between units and moles with full SI prefix support (e.g. kilomoles).
Note that because it is impossible to have fractional "units" in the real world, this class truncates "units" measurements. For example:
var result = units(5.6).as(units); // 5.0
- Inheritance
-
- Object
- Measurement<
Quantity> - Quantity
Constructors
-
Quantity.infinite([MeasurementInterpreter<
Quantity> interpreter = units]) -
Infinite quantity.
const
-
Quantity.negativeInfinite([MeasurementInterpreter<
Quantity> interpreter = units]) -
Infinite negative quantity.
const
-
Quantity.sum(Iterable<
Quantity> parts, {Precision precision = Precision.max}) - Constructs a Quantity representing the sum of any number of other Quantitys.
-
Quantity.zero([MeasurementInterpreter<
Quantity> interpreter = units]) -
The quantity of size zero.
const
Properties
-
defaultInterpreter
→ MeasurementInterpreter<
Quantity> ? -
The default unit for this measurement.
finalinherited
- defaultValue → double
-
Returns the default measurement value (i.e. the measurement as interpreted
by the default MeasurementInterpreter.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isFinite → bool
-
Returns
true
if this measurement is finite.no setterinherited - isInfinite → bool
-
Returns
true
if this measurement is infinite (either positive or negative).no setterinherited - isNaN → bool
-
Returns
true
if this measurement cannot be expressed as a number.no setterinherited - isNegative → bool
-
Returns
true
if this measurement is negative.no setterinherited - precision → int
-
Returns the number of digits of precision this measurement has.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- si → double
-
The SI value this measurement is based on.
finalinherited
Methods
-
acceptVisitor(
MeasurementVisitor visitor) → void -
Accept a visitor object for double-dispatch.
override
-
as(
MeasurementInterpreter< Quantity> interpreter) → double - Interprets this using the specified units.
-
by<
V extends Measurement< (V> >Measurement< V> other) → DerivedMeasurement<Measurement< Quantity> , Measurement<V> > -
Creates a derived unit that is the multiplication of this measurement with another.
inherited
-
compareMagnitude(
Quantity other) → double -
Returns the difference in magnitude between this and another measurement.
inherited
-
compareTo(
Quantity other) → int -
Compares this object to another object.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
per<
V extends Measurement< (V> >Measurement< V> other) → DerivedMeasurement<Measurement< Quantity> , Measurement<V> > -
Creates a derived measurement that is the division of this measurement with another.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
withDefaultUnit(
MeasurementInterpreter< Quantity> interpreter) → Quantity -
Creates a new measurement equivalent to this one but with a different
default unit.
inherited
-
withPrecision(
Precision precision) → Quantity -
Creates an equivalent measurement with the specified precision.
inherited
Operators
-
operator *(
double multiplier) → Quantity -
Returns a measurement equivalent to a multiple of this.
inherited
-
operator +(
Quantity other) → Quantity -
Returns a measurement equivalent to the sum of two others.
inherited
-
operator -(
Quantity other) → Quantity -
Returns a measurement equivalent to the difference between two others.
inherited
-
operator /(
double divisor) → Quantity -
Returns a measurement equivalent to a fraction of this.
inherited
-
operator <(
Quantity other) → bool -
Returns
true
if this is less than the other measurement.inherited -
operator <=(
Quantity other) → bool -
Returns
true
if this is less than or equal to the other measurement.inherited -
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator >(
Quantity other) → bool -
Returns
true
if this is greater than the other measurement.inherited -
operator >=(
Quantity other) → bool -
Returns
true
if this is greater than or equal to the other measurement.inherited -
operator unary-(
) → Quantity -
Returns a measurement representing the opposite of this.
inherited
-
operator ~/(
Quantity other) → int -
Returns the truncating division result of this and another measurement.
inherited