toString method
A string representation of this object.
Some classes have a default textual representation,
often paired with a static parse
function (like int.parse).
These classes will provide the textual representation as
their string representation.
Other classes have no meaningful textual representation
that a program will care about.
Such classes will typically override toString
to provide
useful information when inspecting the object,
mainly for debugging or logging.
Implementation
@override
String toString() {
if (_bytes >= PiB && _bytes % PiB == 0) {
return '${_bytes ~/ PiB}PiB';
}
if (_bytes >= TiB && _bytes % TiB == 0) {
return '${_bytes ~/ TiB}TiB';
}
if (_bytes >= GiB && _bytes % GiB == 0) {
return '${_bytes ~/ GiB}GiB';
}
if (_bytes >= MiB && _bytes % MiB == 0) {
return '${_bytes ~/ MiB}MiB';
}
if (_bytes >= KiB && _bytes % KiB == 0) {
return '${_bytes ~/ KiB}KiB';
}
return '${_bytes}B';
}