BestRazer
BestRazer

Reputation: 377

How to clear the app cache when the app starts

I have a view pdf viewers in my app. These get the pdfs from a url and I switch the pdfs often. my problem is, that the pdfs get stored in the cache for a long time. So if I switch the pdfs and you have the old one still in cache, it will show the old one. Is it possible to clear the cache each time when the app starts?

Upvotes: 1

Views: 529

Answers (1)

johnnydevv
johnnydevv

Reputation: 146

Just by checking the pdf viewers package, it uses this plugin : flutter_cache_manager

First make sure you can use this import.

import 'package:flutter_cache_manager/flutter_cache_manager.dart';

..if not , you can install flutter_cache_manager first.

Then try something like this, inside your method.

DefaultCacheManager().emptyCache();

Upvotes: 1

Related Questions