formatSize static method

String formatSize(
  1. int size, {
  2. bool lowerCase = true,
  3. int fixed = 1,
})

Implementation

static String formatSize(int size, {bool lowerCase = true, int fixed = 1}) {
  for (final item in _fileSizeMap.keys) {
    if (size >= item) {
      final result = item > 0 ? (size / item).toStringAsFixed(fixed) : 0;
      var unit = _fileSizeMap[item];
      if (lowerCase) unit = unit!.toLowerCase();
      return '$result$unit';
    }
  }
  return '';
}