在我的info.plist文件中添加了密钥 io.flutter.embedded_views_preview =是
在webview中加载base 64转换后的html字符串。在...工作正常 android但iOS我在上面提到的错误
String htmlText =getHTML(cp);
final String contentBase64 = base64Encode(const Utf8Encoder().convert(htmlText));
String url = 'data:text/html;base64,$contentBase64';
this.child = WebView(
initialUrl: url,
javascriptMode: JavascriptMode.unrestricted,
javascriptChannels: <JavascriptChannel>[
_cpJavascriptChannel(buildContext,cp),
].toSet(),
onWebViewCreated: (WebViewController webViewController) {
_controller.complete(webViewController);
},
navigationDelegate: (NavigationRequest request) {return NavigationDecision.prevent;}
);
JavascriptChannel _cpJavascriptChannel(BuildContext context, chargePoints.ChargePoint cp) {
return JavascriptChannel(
name: 'ChargePoint',
onMessageReceived: (JavascriptMessage message) {
Navigator.of(buildContext).pushReplacementNamed('/chargePoint',arguments: {'cp':cp,'connector':message.message});
});
}
答案 0 :(得分:0)
这是帮助我解决此问题的代码。
<key>io.flutter.embedded_views_preview</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
了解更多有关新更改的信息。