1

Listview / PageView Widgets do cache data and I don't know where, as well as Image.network and another bunch of widgets do cache data.

I know that you may clear cache by these methods below :- and the methods mentioned in this thread How to clear app cache programmatically on Flutter

   setState(() {
              imageCache.clear();
              imageCache.clearLiveImages();
              PaintingBinding.instance.imageCache.clear();
            });

But I'm not sure that I have deleted ALL cached data allover the app, Are these enough to clear all cached data or there are more ?

and How can you list and view all the cached data that are misteriously hidden somewhere I don't know where !?

please excuse my ignorance

Rageh Azzazy
  • 701
  • 1
  • 7
  • 16

1 Answers1

0

This would not be the answer as I still don't know how to list and read all the data

but I could gather number of functions that make up a good cocktail to cleanup my heavy app

  Future<void> deleteAllCacheThereIsInThisHeavyLaggyAppThatSucksMemoryLikeABlackHole() async {

    await Future.wait(<Future>[

      getTemporaryDirectory().then((Directory directory) async {
        await Directory(directory.path).delete(recursive: true);
      }),

      getApplicationDocumentsDirectory().then((Directory directory) async {
        await Directory(directory.path).delete(recursive: true);
      }),

      DefaultCacheManager().emptyCache(),

    ]);

    imageCache.clear();
    imageCache.clearLiveImages();
    PaintingBinding.instance.imageCache.clear();

  }

notice that i used this package https://pub.dev/packages/flutter_cache_manager as well

Please feel free to add any method that deletes any hidden magical cached file that I do not know about

I prefer to call these methods multiple times rather than having my app too heavy to navigate

Rageh Azzazy
  • 701
  • 1
  • 7
  • 16