fileSize static method
Formats bytes as a human-readable file size.
Implementation
static String fileSize(num bytes, {int precision = 0, int? maxPrecision}) {
const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
var i = 0;
var value = bytes.toDouble();
while (value.abs() >= 1024 && i < units.length - 1) {
value /= 1024;
i++;
}
return '${_formatNumber(value, precision, maxPrecision)} ${units[i]}';
}