MutableQuantity class

MutableQuantity supports updates to its value, dimensions and uncertainty. Changes are broadcast over the onChange stream.

Inversion

The Quantity class supports inversion through the inverse method, which returns a Quantity object that is the result of the inversion process. MiscQuantity adds to this capability with the invert method, which inverts the MiscQuantity in place without returning a object. This is possible because a MiscQuantity may have any Dimensions, whereas other Quantity subclasses have fixed Dimensions.

Implemented types

Constructors

MutableQuantity([Number _valueSI = Double.zero, Dimensions _dimensions = Scalar.scalarDimensions, double _ur = 0.0])
Constructs a instance, with optional SI-MKS value, dimensions and/or relative uncertainty.
MutableQuantity.from(Quantity q)
Constructs a instance from an existing Quantity.

Properties

arbitraryPrecision bool
Whether or not this Quantity is represented using arbitrary precision.
no setteroverride
cgs Number
Returns the value of this quantity in alternative CGS (or centimeter-gram-second) units. MKS (meter-kilogram-second) units are preferred.
getter/setter pairoverride-getter
dimensions Dimensions
Dimensions.
getter/setter pairoverride-getter
hashCode int
Each MutableQuantity has a unique hashCode that is not value based. Therefore MutableQuantity instances with the same value and dimensions as another quantity will not have the same hash code.
no setteroverride
isScalar bool
Whether or not this Quantity has scalar dimensions, including having no angle or solid angle dimensions.
no setteroverride
isScalarSI bool
Whether or not this Quantity has scalar dimensions in the strict International System of Units (SI) sense, which allows non-zero angle and solid angle dimensions.
no setteroverride
mks Number
Returns the value of this quantity in standard MKS (or meter-kilogram-second) units.
getter/setter pairoverride-getter
mutable bool
Mutability can be turned on and off (defaults to true).
getter/setter pair
onChange Stream<Quantity>
Broadcasts a snapshot of quantity whenever its value, dimensions or uncertainty changes.
no setter
preferredUnits Units?
Preferred units for display.
getter/setter pairoverride-getter
relativeUncertainty double
The relative standard uncertainty in this Quantity object's value.
getter/setter pairoverride-getter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
snapshot Quantity
Creates and returns an immutable typed Quantity that represents the value and uncertainty of this MutableQuantity at this moment.
no setter
standardUncertainty Quantity
Returns the standard uncertainty in this Quantity object's value as a typed Quantity object.
getter/setter pairoverride-getter
valueSI Number
The value of the quantity in the base units, of the International System of Units (SI).
getter/setter pairoverride-getter

Methods

abs() Quantity
Converts the value of this MutableQuantity to its absolute value. Returns itself.
override
calcExpandedUncertainty(double k) Quantity
Returns the expanded uncertainty for coverage factor, k, in this Quantity's value as a typed Quantity object.
override
compareTo(dynamic q2) int
Compares this Quantity to q2 by comparing MKS values. The Quantities need not have the same dimensions.
override
inverse() Quantity
Determines the inverse of the quantity represented by this object, creating and returning a Quantity object (which may have different dimensions and therefore be of a different type). This object is not modified.
override
invert() → void
Inverts this MutableQuantity, both value and dimensions, in place.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
outputText(StringBuffer buffer, {UncertaintyFormat uncertFormat = UncertaintyFormat.none, bool symbols = true, NumberFormat? numberFormat}) → void
Appends a String representation of this Quantity to the buffer using the preferred units and number format. If no preferred units have been specified, then MKS units are used. Uncertainty in the value of the Quantity is optionally shown as a plus/minus value in the same units.
override
randomSample() Quantity
Randomly generates a Quantity from this Quantity's value and uncertainty. The uncertainty is represented by a Normal (Gaussian) continuous distribution.
override
setEqualTo(Quantity q2) Quantity
Modifies this MutableQuantity to have the value, dimensions, uncertainty and preferred units of q2.
setValueInUnits(dynamic value, Units units) → void
Sets the this Quantity's value in the specified units. The value is expected to be a num or Number object. The units must match the current dimensions or a DimensionsException will be thrown.
sqrt() Quantity
Returns a Quantity that represents the square root of this Quantity, in terms of both value and dimensions (for example, if this Quantity were an Area of 16 square meters, a Length of 4 meters will be returned).
override
toJson() Map<String, dynamic>
Support dart:convert stringify.
override
toString() String
Returns a String representation of a snapshot of this MutableQuantity .
override
valueInUnits(Units? units) Number
Gets the Quantity's value in the specified units. If units is null, the MKS value is returned. If not null, units must have dimensions compatible with this Quantity or a DimensionsException will be thrown.
override

Operators

operator *(dynamic multiplier) Quantity
Returns the product of this quantity and multiplier, which is expected to be either a Quantity, num or Number object. All other types will cause a QuantityException to be thrown.
override
operator +(dynamic addend) Quantity
Returns the sum of this Quantity and addend.
override
operator -(dynamic subtrahend) Quantity
Returns the difference of this Quantity and subtrahend or (this - q2).
override
operator /(dynamic divisor) Quantity
Returns the quotient of this quantity and divisor, including both value and dimensions.
override
operator <(Quantity other) bool
Determines whether on not this Quantity is less than a specified Quantity by comparing their MKS values. The two Quantities need not be of the same type or dimensions.
override
operator <=(Quantity other) bool
Determines whether on not this Quantity is less than or equal to a specified Quantity by comparing their MKS values. The two Quantities need not be of the same type or dimensions.
override
operator ==(Object other) bool
The equality operator.
override
operator >(Quantity other) bool
Determines whether on not this Quantity is greater than a specified Quantity by comparing their MKS values. The two Quantities need not be of the same type or dimensions.
override
operator >=(Quantity other) bool
Determines whether on not this Quantity is greater than or equal to a specified Quantity by comparing their MKS values. The two Quantities need not be of the same type or dimensions.
override
operator ^(dynamic exp) Quantity
Returns this Quantity raised to the power of exponent.
override
operator unary-() Quantity
Negates the value of this MutableQuantity and returns a reference to itself.
override