VolumeFormat class
Allows a Volume to be formatted.
See UnitOfMeasurementFormat for general notes on the pattern syntax, which you can combine with the VolumeUnit pattern specifiers as required:
Unit | Specifier | |
---|---|---|
S.I. | cubic nanometer | nm³ |
cubic micrometer | μm³ |
|
cubic millimeter | mm³ |
|
milliliter | mL³ |
|
liter | L |
|
cubic meter | m³ |
|
cubic decameter | dam³ |
|
cubic kilometer | km³ |
|
cubic megameter | Mm³ |
|
cubic gigameter | Gm³ |
|
Imperial | cubic thou | thou³ |
imperial teaspoon | tsp_imp |
|
imperial tablespoon | Tbsp_imp |
|
imperial fluid ounce | fl_oz_imp |
|
imperial cup | c_imp |
|
imperial pint | pt_imp |
|
imperial quart | qt |
|
imperial gallon | gal_imp |
|
cubic inch | in³ |
|
cubic foot | ft³ |
|
cubic yard | yd³ |
|
cubic mile | mi³ |
|
U.S. | US teaspoon | tsp_us |
US tablespoon | Tbsp_us |
|
US fluid ounce | fl_oz_us |
|
US customary cup | c_us_customary |
|
US legal cup | c_us_legal |
|
US liquid pint | pt_us |
|
US liquid quart | qt |
|
US liquid gallon | gal_us |
final volume = 42.liters();
// '42L'
final result1 = VolumeFormat().format(volume);
// '42 Liters'
final result2 = VolumeFormat(pattern: '0.## U').format(volume);
// '42,000,000 mm³'
final result3 = VolumeFormat(
pattern: '###,##0.## u:mm³',
permissibleValueUnits: VolumeUnits.si,
).format(volume);
See also:
- Inheritance
-
- Object
- UnitOfMeasurementFormat<
Volume, VolumeUnit> - VolumeFormat
Constructors
-
VolumeFormat({String pattern = '0.##${UnitOfMeasurementFormat.valueUnitSymbolFormatSpecifier}', Set<
VolumeUnit> permissibleValueUnits = VolumeUnits.commonSi, String? locale})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- locale → String?
-
The locale to use when formatting values.
finalinherited
- pattern → String
-
The pattern that indicates the desired output when formatting input values.
finalinherited
-
permissibleRateUnits
→ Set<
RateUnit> -
finalinherited
-
permissibleValueUnits
→ Set<
VolumeUnit> -
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
format(
Volume input) → String -
Formats
input
according to the pattern and locale of this format.inherited -
getLargestUnit(
Volume input) → VolumeUnit -
Determines the largest denomination of unit in
input
that has a value of at least1
.override -
getPatternSpecifierFor(
VolumeUnit valueUnit) → String -
Gets the pattern specifier for the given value unit.
inherited
-
getPermissibleRateUnits(
) → Set< RateUnit> -
Gets a set of permissible
RateUnit
values.inherited -
getPermissibleValueUnits(
) → Set< VolumeUnit> -
Gets a set of permissible
TUnit
values.inherited -
getUnitName(
VolumeUnit unit, String locale) → String -
Gets the a
unit
name in the givenlocale
.inherited -
getUnitQuantity(
Volume input, VolumeUnit unit) → Rational -
Determines how many units of
unit
theinput
contains, including any fractional portion.override -
getUnitSymbol(
VolumeUnit unit, String locale) → String -
Gets the a
unit
symbol in the givenlocale
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pluralizeValueUnits(
String locale) → bool -
Determines whether value units should be pluralized. Defaults to
true
.inherited -
scaleToRateUnit(
Volume input, RateUnit rateUnit) → Volume -
Scales
input
, which is assumed to be a rated unit of measurement, so that its rate israteUnit
.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited