Creating duplicate files in cache with unique file names
As it seems when I try to load an PDF from assets. The Widget creates an copy of the file with unique file name as a cache in app folder.
But as I can see if we reopen the same PDF it creates the duplicate of that same file with new file name. Which results in unnecessary feeling of memory in the cache.
I did not found any inbuilt way in the library itself to get rid of that cache or to validate if that file already present in the cache.
I am attaching detailed Screen shots what I am trying to explain
As you can see I am trying to open this image two times.
D/PDF_RENDER(10331): OpenAssetDocument. Created file: /data/user/0/com.mahayoga.user/cache/59abc52f7cbe4e0fae57c6f6e25d744d.pdf
D/PDF_RENDER(10331): OpenFileDocument. File: /data/user/0/com.mahayoga.user/cache/59abc52f7cbe4e0fae57c6f6e25d744d.pdf
D/PDF_RENDER(10331): OpenAssetDocument. Created file: /data/user/0/com.mahayoga.user/cache/ee6e681802fa426cbb236c7d8b632a18.pdf
D/PDF_RENDER(10331): OpenFileDocument. File: /data/user/0/com.mahayoga.user/cache/ee6e681802fa426cbb236c7d8b632a18.pdf
Which results in creation of this much duplication if we don't handle cache manually

So If there some issue from side to understand the documentation please show me the right direction else. Please provide an inbuilt method to manage duplication.
Any replies on this ?
I need to be sure cached documents are disposed when disposing the pdf-renderer. Any news here?
@nachikamod Did you find any solution? I'm facing the same problem.
Not in the library @Firas-Amin but I implemented a crude (Brute force approach) solution. Which basically reads the cache and clears all the pdf files. Now since we can't know the file name saved in the cache, because the library saves this file in the cache with randomly generated names, I delete all the cache pdf files instead.
// Run this two lines before opening any pdf file
String _cacheDir = (await getTemporaryDirectory()).path;
new Directory(_cacheDir).delete(recursive: true);
// Open pdf file here
So, this is simple implementation you can employ with path_provider package which basically reads application's cache directory and delete all the contents. But you can modify this by reading the directory and only deleting the pdf files unlike I am clearing out all the cache (Cause, my application didn't required file caching so only thing was caching was of from this library).
Thank you for the code @nachikamod. For some reasons, it seems it doesn't clear the cache while navigating between pages. For example, I have a PDF file with 80mb size. When the user starts the application, 80mb cache added to the application and when they go to the index and pick different page from the PDF and navigate to it another 80mb added .
Let's connect on discord
Check my request as 4RB1TR4RY#1264
Any updates on this? This is important
Any updates on this? This is important
No updates yet from the maintainer.