InformationRateFormat class

Allows an InformationRate to be formatted.

See UnitOfMeasurementFormat for general notes on the pattern syntax and InformationSizeFormat for information-specific notes.

final informationRate = 42.kilobytes().per(const Duration(seconds: 1));

// '41.02 KiB/s'
final result1 = InformationRateFormat().format(informationRate);

// '41.02 kibibytes per second'
final result2 = InformationRateFormat(pattern: "0.## U 'per' R").format(informationRate);

// '151,200 KB/hr'
final result3 = InformationRateFormat(
  pattern: "###,##0.## u:KB'/'r:hr",
  permissibleValueUnits: InformationUnits.siBytes,
).format(informationRate);

See also:

Inheritance

Constructors

InformationRateFormat({String pattern = "0.## ${UnitOfMeasurementFormat.valueUnitSymbolFormatSpecifier}'/'${UnitOfMeasurementFormat.rateUnitSymbolFormatSpecifier}", Set<InformationUnit> permissibleValueUnits = InformationUnits.iecBytes, Set<RateUnit> permissibleRateUnits = RateUnits.hourOrLess, 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<InformationUnit>
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

format(InformationRate input) → String
Formats input according to the pattern and locale of this format.
inherited
getLargestUnit(InformationRate input) → InformationUnit
Determines the largest denomination of unit in input that has a value of at least 1.
override
getPatternSpecifierFor(InformationUnit 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<InformationUnit>
Gets a set of permissible TUnit values.
inherited
getUnitName(InformationUnit unit, String locale) → String
Gets the a unit name in the given locale.
inherited
getUnitQuantity(InformationRate input, InformationUnit unit) → Decimal
Determines how many units of unit the input contains, including any fractional portion.
override
getUnitSymbol(InformationUnit unit, String locale) → String
Gets the a unit symbol in the given locale.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
scaleToRateUnit(InformationRate input, RateUnit rateUnit) → InformationRate
Scales input, which is assumed to be a rated unit of measurement, so that its rate is rateUnit.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited