toFileSize property

String get toFileSize

Gets file size from byte to YB

Implementation

String get toFileSize {
  if (this <= 0) return "0 B";
  List<String> units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
  int i = (log(this) / log(1024)).floor();
  return '${(this / pow(1024, i)).toStringAsFixed(2)} ${units[i]}';
}