normalizeFileSize static method

String normalizeFileSize(
  1. double value
)

格式化大小

Implementation

static String normalizeFileSize(double value) {
  double v = value;
  List<String> unitArr = ['B', 'K', 'M', 'G'];
  int index = 0;
  while (v > 1024) {
    index++;
    v = v / 1024;
  }
  String size = v.toStringAsFixed(1);
  return size + unitArr[index];
}