formatBytes method
计算大小
Implementation
String formatBytes({int decimals = 2}) {
if (this <= 0) return '0M';
const unitArr = ["B", "KB", "MB", "GB", "TB"];
var index = 0;
double size = toDouble();
while (size > 1024) {
index++;
size /= 1024;
}
return '${size.toStringAsFixed(decimals)} ${unitArr[index]}';
}