1234567891011121314151617 |
- formatSize(double? value, {int fixed = 2}) {
- if (value == 0) return "0M";
- List<String> unitArr = ['B', 'K', 'M', 'G'];
- int index = 0;
- while (value! > 1024) {
- index++;
- value = value/ 1024;
- }
- String size = value.toStringAsFixed(fixed);
- return size + unitArr[index];
- }
- toString(double? value, {int fractionDigits = 1}){
- if(value == null)return "";
- if(value.toInt() == value)return value.toStringAsFixed(0);
- else return value.toStringAsFixed(fractionDigits);
- }
|