Density class final
Represents a quantity of density.
Density is a physical quantity representing the mass per unit volume of a substance. The SI derived unit is Kilogram per Cubic Meter (kg/m³).
- Inheritance
-
- Object
- Quantity<
DensityUnit> - LinearQuantity<
DensityUnit, Density> - Density
- Available extensions
- Annotations
-
- @immutable
Constructors
- Density(double _value, DensityUnit _unit)
-
Creates a new
Densitywith a given value and unit.const - Density.from(Mass mass, Volume volume)
-
Creates a
Densityfrommassandvolume(ρ = m / V).factory
Properties
- asGramsPerCubicCentimeter → Density
-
Available on Density, provided by the DensityValueGetters extension
Returns a new Density object representing this density in Grams per Cubic Centimeter (g/cm³).no setter - asGramsPerMilliliter → Density
-
Available on Density, provided by the DensityValueGetters extension
Returns a new Density object representing this density in Grams per Milliliter (g/mL).no setter - asKilogramsPerCubicMeter → Density
-
Available on Density, provided by the DensityValueGetters extension
Returns a new Density object representing this density in Kilograms per Cubic Meter (kg/m³).no setter - hashCode → int
-
Returns a hash code for this
Quantityinstance.no setterinherited - inGramsPerCubicCentimeter → double
-
Available on Density, provided by the DensityValueGetters extension
Returns the density value in Grams per Cubic Centimeter (g/cm³).no setter - inGramsPerMilliliter → double
-
Available on Density, provided by the DensityValueGetters extension
Returns the density value in Grams per Milliliter (g/mL).no setter - inKilogramsPerCubicMeter → double
-
Available on Density, provided by the DensityValueGetters extension
Returns the density value in Kilograms per Cubic Meter (kg/m³).no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- unit → DensityUnit
-
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< DensityUnit> other) → int -
Compares this quantity to another Quantity of the same type (
T).inherited -
convertTo(
DensityUnit targetUnit) → Density -
Creates a new
Qinstance with the value converted totargetUnit.inherited -
create(
double value, DensityUnit unit) → Density -
Factory that creates a new instance of the concrete subtype
Q.override -
getValue(
DensityUnit targetUnit) → double -
Returns the value of this quantity converted to
targetUnit.inherited -
isEquivalentTo(
Quantity< DensityUnit> 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
-
massOf(
Volume volume) → Mass - Calculates the Mass of a given Volume of this substance.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
ratioTo(
Quantity< DensityUnit> other) → double -
Computes the dimensionless ratio of this quantity to
other.inherited -
toString(
{DensityUnit? targetUnit, QuantityFormat format = QuantityFormat.invariant}) → String -
Returns a string representation of this quantity.
inherited
-
volumeFor(
Mass mass) → Volume - Calculates the Volume required for a given Mass of this substance.
Operators
-
operator *(
double scalar) → Density -
Multiplies this quantity by a dimensionless
scalar.inherited -
operator +(
Density other) → Density -
Adds
otherto this quantity.inherited -
operator -(
Density other) → Density -
Subtracts
otherfrom this quantity.inherited -
operator /(
double scalar) → Density -
Divides this quantity by a dimensionless
scalar.inherited -
operator <(
Quantity< DensityUnit> other) → bool -
Checks if this quantity's magnitude is less than another's.
inherited
-
operator <=(
Quantity< DensityUnit> 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< DensityUnit> other) → bool -
Checks if this quantity's magnitude is greater than another's.
inherited
-
operator >=(
Quantity< DensityUnit> other) → bool -
Checks if this quantity's magnitude is greater than or equal to another's.
inherited
-
operator unary-(
) → Density -
Negates this quantity.
inherited
Static Properties
-
parser
→ QuantityParser<
DensityUnit, Density> -
The parser instance used to convert strings into Density objects.
final
Static Methods
-
parse(
String input, {List< QuantityFormat> formats = const [QuantityFormat.invariant]}) → Density - Parses a string representation of density into a Density object.
-
tryParse(
String input, {List< QuantityFormat> formats = const [QuantityFormat.invariant]}) → Density? -
Parses a string representation of density into a Density object,
returning
nullwhen parsing fails.