LinearQuantity<T extends LinearUnit<T>, Q extends LinearQuantity<T, Q>> class abstract base

An abstract base class for physical quantities with linear (factor-based) unit conversions.

Extends Quantity with a generic implementation of arithmetic operators (+, -, *, /) and convertTo, eliminating the need to reimplement these in every concrete quantity class.

Inheritance
Implementers
Annotations
  • @immutable

Constructors

LinearQuantity(double _value, T _unit)
Creates a new LinearQuantity with the given value and unit.
const

Properties

hashCode int
Returns a hash code for this Quantity instance.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
unit → T
Returns the unit of measurement associated with this quantity's original value.
no setterinherited
value double
Returns the numerical value of this quantity in its original unit.
no setterinherited

Methods

compareTo(Quantity<T> other) int
Compares this quantity to another Quantity of the same type (T).
inherited
convertTo(T targetUnit) → Q
Creates a new Q instance with the value converted to targetUnit.
override
create(double value, T unit) → Q
Factory that creates a new instance of the concrete subtype Q.
getValue(T targetUnit) double
Returns the value of this quantity converted to targetUnit.
override
isEquivalentTo(Quantity<T> other, {double tolerance = 1e-9, double absoluteTolerance = 0.0}) bool
Checks if this quantity has the same physical magnitude as another, accounting for IEEE 754 floating-point rounding inaccuracies.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
ratioTo(Quantity<T> other) double
Computes the dimensionless ratio of this quantity to other.
toString({T? targetUnit, QuantityFormat format = QuantityFormat.invariant}) String
Returns a string representation of this quantity.
inherited

Operators

operator *(double scalar) → Q
Multiplies this quantity by a dimensionless scalar.
operator +(Q other) → Q
Adds other to this quantity.
operator -(Q other) → Q
Subtracts other from this quantity.
operator /(double scalar) → Q
Divides this quantity by a dimensionless scalar.
operator <(Quantity<T> other) bool
Checks if this quantity's magnitude is less than another's.
inherited
operator <=(Quantity<T> other) bool
Checks if this quantity's magnitude is less than or equal to another's.
inherited
operator ==(Object other) bool
Determines whether this Quantity is equal to another Object.
inherited
operator >(Quantity<T> other) bool
Checks if this quantity's magnitude is greater than another's.
inherited
operator >=(Quantity<T> other) bool
Checks if this quantity's magnitude is greater than or equal to another's.
inherited
operator unary-() → Q
Negates this quantity.