Search code examples
flutterdartflutterwebviewplugin

Precache html pages in flutter


I have a list of some HTML pages that i show in my web_view. The problem is that it will load slowly when network is slow or wont show at all if user is offline. So i want to pre-cache all the URLs before navigating to that page. After that I want to load from the cache and navigate through the URLs on swipe. (The Swipe part is done with URLs loading real-time). My question to you is how do I pre-cache every URLs and call it in my web_view later


Solution

  • If you are sure that those pages are static..I have a suggestion for you..

    Like you said, you can pre-cache..

    Initially, when internet is available you get the code of those URLs using http package and store it in local storage, say some .txt file.

    And then, when you want to show the page in your app, again..as it being static page, you can read the html code from local storage and show it in your app using html package.

    Hope it answers your question.