How to save website for offline in flutter mobile
Asked Answered
W

3

12

Important note - I want this functionality for mobile apps only, not for flutter web.

I am having some trouble saving the website inside the flutter app. I have tried using the cache method and savewebarchive method for the inappwebview. The issue with the method is that it is not saving the full content of the website. It is only saving HTML and CSS files.

I want to save the whole website with all the content like HTML, CSS, js, font files, Images and store it inside the flutter app. I have gone through a few plugins but none of them were helpful.

I am looking for the same functionality as httrack.

Any right direction would be appriciated.

Weinberger answered 26/10, 2021 at 10:51 Comment(1)
The bounty has ended and is not refundable. You can reward an answer that helps you.Arevalo
A
4

Without existing Flutter plugins, one of the quickest approach is to simply use Android and iOS plugins, and write a simple Flutter wrapper around it.

For android, you may be interested in this link. For iOS, this link may be helpful. These links are just examples - you can search further on Google to find out more plugins that suit your needs. (For example, search android kotlin save whole website etc).

After the solution is found on android and ios, you can develop a Flutter plugin very easily in order to let your Flutter code call those Android/iOS snippets. Personally I suggest use Kotlin for Android, Swift for iOS, and do not forget pigeon for code generation.

By the way, if you want to draw some UI with Android/iOS code instead of Flutter code, you may also be interested in platform views.

Arevalo answered 8/11, 2021 at 9:33 Comment(10)
I have tried using it that way but some files are not present inside the archive itself. like the files with .blob and .woff extention that carries some data inside the webpage itself.Weinberger
@rajkavadia So you may need to create another question asking about android and ios. btw which platform do you fail? what methods have you tried?Arevalo
@rajkavadia any updates?Arevalo
@rajkavadia Congratulations!Arevalo
sorry its not working on the site that i want.Weinberger
its not fatching sites with blobs and woff files.Weinberger
@rajkavadia what method have you tried? there are a lot of methods for android/ios and you may try othersArevalo
Have tried this link and also tried JSOUP for java but it's not working on specific sites.Weinberger
@rajkavadia hmm have you tried others? that is more like a pure-android problem.Arevalo
@rajkavadia Hi the bounty (it is non-refundable) is going to end in 2 hours. Have you made any progress?Arevalo
B
1

Since you asked for some directions:

If you already know which websites you want to be able to view offline, you can use HTTrack to download them and bundle the files generated in your Flutter application.

If you want to be able to dynamically download websites, there is currently no Dart/Flutter package that will do the website ripping for you. You would either have to implement it yourself, or perhaps make an API that would use an already made program (HTTrack for example) and then send the files to your application.

Bumf answered 4/11, 2021 at 13:45 Comment(0)
L
-1

You can use webview_flutter and html plugin to download whole website as code, store it as a String variable then you can open it by using webview_flutter.

Leeth answered 26/10, 2021 at 13:10 Comment(1)
It saves the HTML file, yes but it is not saving the whole content of the website like images font files.Weinberger

© 2022 - 2025 — McMap. All rights reserved.