从Flutter中对WebView小部件的响应中注入HTML正文

时间:2020-09-30 10:02:10

标签: flutter webview webview-flutter

我正在使用webview_flutter插件在我的应用程序中调用Webview。我有一个用例,其中我收到的响应正文为HTML。

<html>
 <body onload='document.forms["form"].submit()'>
    <form name='form' action='siteLinkWidget' method='post'></form>
 </body>
</html>

此HTML代码将通过提交表单自动调用action并显示页面。

下面是我的WebView()小部件代码:

WebView(
    // initialUrl: 'about:blank', // Commented out as it is not a required attribute
    debuggingEnabled: true,
    onWebViewCreated: (WebViewController webViewController) async {
      _controller = webViewController;
      _controller.evaluateJavascript("document.write('<html>')"
          "document.write( '<body onload=\'document.forms[\"form\"].submit()\'>');"
          "document.write( '<form name=\'form\' action=\'siteLinkWidget\' method=\'post\'></form>' );"
           "document.write( '</body></html>' );");
      },
      javascriptMode: JavascriptMode.unrestricted,
),

上面的窗口小部件在控制台上显示空白屏幕,没有错误消息。虽然我有一些日志,但请检查以下内容:

V / ViewRootImpl(11541):指定的消息队列同步屏障令牌尚未发布或已被删除

E / InputMethodManager(11541):b / 117267690:无法获得具有预期displayId = 82实际IMM#displayId = 0的后备IMM的视图= io.flutter.plugins.webviewflutter.InputAwareWebView {19f7037 VFEDHVC ...... .... 0,0-1080,1992}

0 个答案:

没有答案