Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
744 views
in Technique[技术] by (71.8m points)

webview - 如何从资产加载完整的网站?(How to load complete website from assets?)

Is there any possibility to load complete website (including associated files) from local assets ?

(是否有可能从本地资产加载完整的网站(包括相关文件)?)

I tried it with flutter plugin webview_flutter and loaded index.html.

(我尝试使用flutter插件webview_flutter并加载了index.html。)

  Future<String> loadLocal() async {
    return await rootBundle.loadString('assets/mywebsite/index.html');
  }

only html code is being rendered and associated javascripts are not working.

(仅呈现html代码,并且相关的javascript无法正常工作。)

  ask by Shahzad Akram translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can follow https://github.com/flutter/flutter/issues/27086

(您可以关注https://github.com/flutter/flutter/issues/27086)

In the meantime you can implement a web server in Dart that serves files from assets and point the webview to that integrated web server.

(同时,您可以在Dart中实现一个Web服务器,该服务器提供资产中的文件并将Web视图指向该集成Web服务器。)

https://medium.com/@segaud.kevin/facebook-oauth-login-flow-with-flutter-9adb717c9f2e is about how to do that in Dart.

(https://medium.com/@segaud.kevin/facebook-oauth-login-flow-with-flutter-9adb717c9f2e关于如何在Dart中做到这一点。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...