getFileSizeWithUnit static method

String getFileSizeWithUnit(
  1. int size
)

Implementation

static String getFileSizeWithUnit(int size) {
  double kb = size / 1000;
  double mb = size / 1000000;

  if (kb < 1024) {
    return '${kb.toStringAsFixed(2)} KB';
  } else {
    return '${mb.toStringAsFixed(2)} MB';
  }
}