formatFileSize property
String
get
formatFileSize
格式化文件大小描述
Implementation
String get formatFileSize {
if (this != null) {
List<String> unitArr = ['B', 'K', 'M', 'G'];
int index = 0;
var value = this?.toDouble() ?? 0;
if (value == 0) {
return "0M";
}
while (value > 1024) {
index++;
value = value / 1024;
}
String size = value.toStringAsFixed(2);
return size + unitArr[index];
}
return '0M';
}