InformationSizeFormat class
Allows an InformationSize to be formatted.
See UnitOfMeasurementFormat for general notes on the pattern syntax, which you can combine with the InformationUnit pattern specifiers as required:
Unit | Specifier | |
---|---|---|
S.I. | bit | b |
crumb | crumb |
|
nibble | nibble |
|
kilobit | kbit |
|
megabit | Mbit |
|
gigabit | Gbit |
|
terabit | Tbit |
|
petabit | Pbit |
|
exabit | Ebit |
|
zettabit | Zbit |
|
yottabit | Ybit |
|
byte | B |
|
kilobyte | KB |
|
megabyte | MB |
|
gigabyte | GB |
|
terabyte | TB |
|
petabyte | PB |
|
exabyte | EB |
|
zettabyte | ZB |
|
yottabyte | YB |
|
I.E.C. | kibibit | Kibit |
mebibit | Mibit |
|
gibibit | Gibit |
|
tebibit | Tibit |
|
pebibit | Pibit |
|
exbibit | Eibit |
|
zebibit | Zibit |
|
yobibit | Yibit |
|
kibibyte | KiB |
|
mebibyte | MiB |
|
gibibyte | GiB |
|
tebibyte | TiB |
|
pebibyte | PiB |
|
exbibyte | EiB |
|
zebibyte | ZiB |
|
yobibyte | YiB |
final informationSize = 42000.bytes();
// '41.02KiB'
final result1 = InformationSizeFormat().format(informationSize);
// '42KB'
final result2 = InformationSizeFormat(
permissibleValueUnits: InformationUnits.siBytes,
).format(informationSize);
// '41.02 kibibytes'
final result3 = InformationSizeFormat(pattern: '0.## U').format(informationSize);
// '0.04 MiB'
final result4 = InformationSizeFormat(pattern: '0.## u:MiB').format(informationSize);
See also:
- Inheritance
-
- Object
- UnitOfMeasurementFormat<
InformationSize, InformationUnit> - InformationSizeFormat
Constructors
-
InformationSizeFormat({String pattern = '0.##${UnitOfMeasurementFormat.valueUnitSymbolFormatSpecifier}', Set<
InformationUnit> permissibleValueUnits = InformationUnits.iecBytes, 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(
InformationSize input) → String -
Formats
input
according to the pattern and locale of this format.inherited -
getLargestUnit(
InformationSize input) → InformationUnit -
Determines the largest denomination of unit in
input
that has a value of at least1
.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 givenlocale
.inherited -
getUnitQuantity(
InformationSize input, InformationUnit unit) → Rational -
Determines how many units of
unit
theinput
contains, including any fractional portion.override -
getUnitSymbol(
InformationUnit 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(
InformationSize input, RateUnit rateUnit) → InformationSize -
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