As I have been developing app using Flutter. I came to find that app is heavy in size plus it is using a lot of space as app data and app cache. Is there any way to clear app cache programmatically?
Edit: my app's size in release mode is about 7mb and app data is about 11mb. My app opens one site within app and it also streams online radio so it's app data goes on increasing
Go to Tools > Flutter > Flutter Clean to clear the build cache of the Flutter project.
0" Then follow the steps: Run flutter upgrade in the terminal to upgrade Flutter Run dart migrate to run the dart migration tool. Solve all errors which the migration tool shows. Run flutter pub outdated --mode=null.
Use the DefaultCacheManager object by calling emptyCache() method, this clears the cache data. DefaultCacheManager manager = new DefaultCacheManager(); manager. emptyCache(); //clears all data in cache.
You can get the temp folder, and delete files in it.
var appDir = (await getTemporaryDirectory()).path;
new Directory(appDir).delete(recursive: true);
You can also use use flutter_cache_manager to delete or remove your app's cache programatically.
After installing flutter_cache_manager
, use this :
await DefaultCacheManager().emptyCache();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With