fileSize property

String? get fileSize

Get FIle Size in MB and KB

Implementation

String? get fileSize {
  if (this != null) {
    int totalBytes = this!.readAsBytesSync().lengthInBytes;
    int totalKB = totalBytes ~/ 1000;
    if (totalKB >= 1000) {
      int totalMB = totalKB ~/ 1000;
      return "$totalMB MB";
    }
    return "$totalKB KB";
  }
  return null;
}