How to render a local HTML file with flutter dart webview

后端 未结 8 1984
孤城傲影
孤城傲影 2020-12-02 18:48

I want to render a local HTML file stored in my phone memory in webview using flutter and dart.

8条回答
  •  天命终不由人
    2020-12-02 19:27

    You can pass a data URI

    Uri.dataFromString('hello world', mimeType: 'text/html').toString()
    

    or you can launch a web server inside Flutter and pass an URL that points to the IP/port the server serves the file from.

    See also the discussion in https://github.com/fluttercommunity/flutter_webview_plugin/issues/23

    See https://flutter.io/docs/development/ui/assets-and-images#loading-text-assets about how to load a string from assets.

    See https://flutter.io/docs/cookbook/persistence/reading-writing-files for how to read other files.

提交回复
热议问题