byteFormat method
String
byteFormat(
{ - int toStringAsFixed = 2,
})
Implementation
String byteFormat({int toStringAsFixed = 2}) {
var result = this;
if (result < 1024) {
return '${result.toStringAsFixed(0)}B';
} else {
result = result / 1024;
}
if (result < 1024) {
return '${result.toStringAsFixed(toStringAsFixed)}K';
} else {
result = result / 1024;
}
if (result < 1024) {
return '${result.toStringAsFixed(toStringAsFixed)}M';
} else {
result = result / 1024;
}
if (result < 1024) {
return '${result.toStringAsFixed(toStringAsFixed)}G';
} else {
result = result / 1024;
}
return '${result.toStringAsFixed(toStringAsFixed)}T';
}