Length class final

Represents a physical quantity of length.

Length is a fundamental physical quantity representing the distance between two points. The SI base unit is the Meter (m).

This class provides a type-safe way to handle length values, convert between different units (e.g., meters, feet, miles), and perform arithmetic operations.

Inheritance
Available extensions
Annotations
  • @immutable

Constructors

Length(double _value, LengthUnit _unit)
Creates a new Length quantity with the given numericalvalue and unit.
const

Properties

asAngstrom Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Ångströms (Å).
no setter
asAU Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Astronomical Units (AU).
no setter
asCm Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Centimeters (cm).
no setter
asDam Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Decameters (dam).
no setter
asDm Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Decimeters (dm).
no setter
asFm Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Femtometers (fm).
no setter
asFt Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Feet (ft).
no setter
asGigaM Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Gigameters (Gm).
no setter
asHm Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Hectometers (hm).
no setter
asInch Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Inches (in).
no setter
asKm Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Kilometers (km).
no setter
asLy Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Light Years (ly).
no setter
asM Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Meters (m).
no setter
asMegaM Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Megameters (Mm).
no setter
asMi Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Miles (mi).
no setter
asMm Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Millimeters (mm).
no setter
asNm Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Nanometers (nm).
no setter
asNmi Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Nautical Miles (nmi).
no setter
asPc Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Parsecs (pc).
no setter
asPm Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Picometers (pm).
no setter
asUm Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Micrometers (μm).
no setter
asYd Length

Available on Length, provided by the LengthValueGetters extension

Returns a Length representing this length in Yards (yd).
no setter
hashCode int
Returns a hash code for this Quantity instance.
no setterinherited
inAngstrom double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Ångströms (Å).
no setter
inAU double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Astronomical Units (AU).
no setter
inCm double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Centimeters (cm).
no setter
inDam double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Decameters (dam).
no setter
inDm double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Decimeters (dm).
no setter
inFm double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Femtometers (fm).
no setter
inFt double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Feet (ft).
no setter
inGigaM double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Gigameters (Gm).
no setter
inHm double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Hectometers (hm).
no setter
inInch double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Inches (in).
no setter
inKilometers double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Kilometers (km).
no setter
inKm double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Kilometers (km).
no setter
inLy double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Light Years (ly).
no setter
inM double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Meters (m).
no setter
inMegaM double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Megameters (Mm).
no setter
inMi double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Miles (mi).
no setter
inMm double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Millimeters (mm).
no setter
inNm double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Nanometers (nm).
no setter
inNmi double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Nautical Miles (nmi).
no setter
inPc double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Parsecs (pc).
no setter
inPm double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Picometers (pm).
no setter
inUm double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Micrometers (μm).
no setter
inYd double

Available on Length, provided by the LengthValueGetters extension

Returns the length value in Yards (yd).
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
unit LengthUnit
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<LengthUnit> other) int
Compares this quantity to another Quantity of the same type (T).
inherited
convertTo(LengthUnit targetUnit) Length
Creates a new Q instance with the value converted to targetUnit.
inherited
create(double value, LengthUnit unit) Length
Factory that creates a new instance of the concrete subtype Q.
override
getValue(LengthUnit targetUnit) double
Returns the value of this quantity converted to targetUnit.
inherited
isEquivalentTo(Quantity<LengthUnit> 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<LengthUnit> other) double
Computes the dimensionless ratio of this quantity to other.
inherited
toString({LengthUnit? targetUnit, QuantityFormat format = QuantityFormat.invariant}) String
Returns a string representation of this quantity.
inherited

Operators

operator *(double scalar) Length
Multiplies this quantity by a dimensionless scalar.
inherited
operator +(Length other) Length
Adds other to this quantity.
inherited
operator -(Length other) Length
Subtracts other from this quantity.
inherited
operator /(double scalar) Length
Divides this quantity by a dimensionless scalar.
inherited
operator <(Quantity<LengthUnit> other) bool
Checks if this quantity's magnitude is less than another's.
inherited
operator <=(Quantity<LengthUnit> 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<LengthUnit> other) bool
Checks if this quantity's magnitude is greater than another's.
inherited
operator >=(Quantity<LengthUnit> other) bool
Checks if this quantity's magnitude is greater than or equal to another's.
inherited
operator unary-() Length
Negates this quantity.
inherited

Static Properties

parser QuantityParser<LengthUnit, Length>
The parser instance used to convert strings into Length objects.
final

Static Methods

parse(String input, {List<QuantityFormat> formats = const [QuantityFormat.invariant]}) Length
Parses a string representation of a length into a Length object.
tryParse(String input, {List<QuantityFormat> formats = const [QuantityFormat.invariant]}) Length?
Parses a string representation of a length into a Length object, returning null if the string cannot be parsed.