formatFileSize method

String formatFileSize()

Implementation

String formatFileSize() {
  if (this < 1000) {
    return '${this}B';
  } else if (this < 1000 * 1000) {
    var temp = this / 1000;
    return '${temp.toStringAsFixed(2)}KB';
  } else if (this < 1000 * 1000 * 1000) {
    var temp = this / 1000 / 1000;
    return '${temp.toStringAsFixed(2)}MB';
  } else {
    var temp = this / 1000 / 1000 / 1000;
    return '${temp.toStringAsFixed(2)}GB';
  }
}