Search code examples
webviewflutterlocal-web-server

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.

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

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


Solution

  • You can follow 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.

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