formatSize static method
将文件大小格式化为 'B', 'K', 'M', 'G'
Implementation
static String formatSize(double value) {
if (value == 0) {
return '0';
}
List<String> unitArr = ['B', 'K', 'M', 'G'];
int index = 0;
while (value > 1024) {
index++;
value = value / 1024;
}
String size = value.toStringAsFixed(2);
return size + unitArr[index];
}