mboeddeker/disk_space

Incorrect total diskspace

Opened this issue · 1 comments

I am not sure if anyone else is facing this issue. I am using this package to get to make file manager. However, My 128GB phone is showing only 97 GB.

Mentioned below is function I am using for printing disksize;

Future initDiskSpace() async {
double diskSpace = 0;

double _diskSpace = 0;
Map<Directory, double> _directorySpace = {};

// diskSpace = await DiskSpace.getFreeDiskSpace;

List<Directory> directories = [];
Map<Directory, double> directorySpace = {};

if (Platform.isIOS) {
  directories = [await getApplicationDocumentsDirectory()];
} else if (Platform.isAndroid) {
  directories =
      await getExternalStorageDirectories(type: StorageDirectory.dcim).then(
    (list) async => list ?? [await getApplicationDocumentsDirectory()],
  );
}

for (var directory in directories) {
  var _diskSpace = await DiskSpace.getTotalDiskSpace;
  directorySpace.addEntries([MapEntry(directory, _diskSpace!)]);
}

// if (!mounted) return;

print(_diskSpace);
print(directorySpace);

}

Hi @findsarfaraz, I'm not the author of this package but by accident I was reading through the issues and I might be able to answer your question.

Android devices use disk partitions. So while a phone that is marketed as 128 GB probably actually has a 128 GB storage chip, its space is divided between a "System" partition and a "Data" partition.

This System partition contains the Android OS. Depending on the vendor, the system image can get quite large (e.g. Samsung Galaxy S20 images are 5 GB already when compressed).

What you are seeing should be the size of the Data partition which is where your downloaded apps go, any data your apps store on your phone, as well as your personal data like photos you might have taken, file downloads, etc.

Unfortunately I'm not aware of any API features that allow you to get the "marketed total disk space" of a device.