Unit class

Describes a storage amount unit

While a public constructor is provided you should really consider this as a enum class instead.

Provided values:

  • Unit.auto: Default, special, unit, which instructs the formatting code to chose automatically choose the best unit based on the provided inputs.
  • Unit.byte: While it is marked as a decimal based unit it does also refer to binary based unit.

Decimal (1000-based multiplier) units

Binary (1024-based multiplier) units

Constructors

Unit(String name, double multiplier, UnitType type)
Primary constructor
const

Properties

hashCode int
The hash code for this object.
no setterinherited
multiplier double
final
name String
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type UnitType
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

bestFor(double amount, [UnitType type = UnitType.binary]) Unit
Determines the best unit for given amount and type.
find(String name) Unit
Find a predefined unit by its name.

Constants

auto → const Unit
byte → const Unit
exabyte → const Unit
exbibyte → const Unit
gibibyte → const Unit
gigabyte → const Unit
kibibyte → const Unit
kilobyte → const Unit
mebibyte → const Unit
megabyte → const Unit
pebibyte → const Unit
petabyte → const Unit
tebibyte → const Unit
terabyte → const Unit
yobibyte → const Unit
yottabyte → const Unit
zebibyte → const Unit
zettabyte → const Unit