iOS Development

ios – Why is my flutter app utilizing a lot storage in ‘Paperwork & Information’?

I’m at present perplexed as to why my app is utilizing a lot storage, as displayed in iPhone Storage settings.

Screenshot of my app's storage in iPhone settings

I ran the next technique to get an approximation of how a lot storage im utilizing in my app:

Future<void> listFilesInAllDirectories() async {
  ultimate Listing tempDir = await getTemporaryDirectory();
  ultimate Listing appDocDir = await getApplicationDocumentsDirectory();
  ultimate Listing appSupportDir = await getApplicationSupportDirectory();
  ultimate Listing libraryDir = await getLibraryDirectory();

  Listing<Listing> directories = [tempDir, appDocDir, appSupportDir, libraryDir];

  int grandTotalSize = 0;

  for (var listing in directories) {
    int totalSize = await getDirectorySize(listing);

    if (totalSize > 0) { // Skip over directories that don't comprise any information
      grandTotalSize += totalSize;
      print("Listing: ${listing.path}");
      double sizeInMB = totalSize / (1024 * 1024);
      print("Complete measurement of listing: ${sizeInMB.toStringAsFixed(2)} MB");

  double grandTotalSizeInMB = grandTotalSize / (1024 * 1024);
  print("Grand whole measurement: ${grandTotalSizeInMB.toStringAsFixed(2)} MB");

Future<int> getDirectorySize(Listing dir) async {
  int measurement = 0;
  attempt {
    Listing<FileSystemEntity> youngsters = dir.listSync();
    for (var youngster in youngsters) {
      if (youngster is File) {
        measurement += await youngster.size();
      } else if (youngster is Listing) {
        measurement += await getDirectorySize(youngster);
  } catch (e) {
    print("An error occurred: $e");
  return measurement;

And this technique outputted the next:

flutter: Listing: /var/cellular/Containers/Information/Software/4258E4C7-1B2C-428F-BCB5-782683E12F51/Library/Caches
flutter: Complete measurement of listing: 7.18 MB
flutter: Listing: /var/cellular/Containers/Information/Software/4258E4C7-1B2C-428F-BCB5-782683E12F51/Paperwork
flutter: Complete measurement of listing: 146.43 MB
flutter: Listing: /var/cellular/Containers/Information/Software/4258E4C7-1B2C-428F-BCB5-782683E12F51/Library/Software Help
flutter: Complete measurement of listing: 0.11 MB
flutter: Listing: /var/cellular/Containers/Information/Software/4258E4C7-1B2C-428F-BCB5-782683E12F51/Library
flutter: Complete measurement of listing: 12.49 MB
flutter: Grand whole measurement: 166.21 MB

For Context, in my app I at present am solely storing photos completely within the Software Paperwork Listing. I do use the Non permanent Listing nonetheless I delete all information I create on this folder after they’ve been used for his or her goal. And earlier than I ran this ‘experiment’, I cleaned this folder with one other dart script.

I’d actually admire if somebody has any suspicions of what’s going on right here and will present an evidence as to how my app is utilizing a lot storage in Paperwork & Information?


Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button