1

我在这里https://pub.dev/packages/flutter_inappwebview的 Flutter InAppWebView 插件版本 4.0.0+4 遇到了一个奇怪的问题,我尝试将简单的联系我们表单加载到插件中并意识到我不能如果我使用非英文键盘,则将内容输入到 html 输入文本字段中,在我的情况下,我使用越南语键盘。如果我将键盘切换到英文键盘,那么它就可以工作了。我仔细检查了联系我们表格,并确保它在 Flutter 应用程序之外的 Chrome 浏览器上 100% 工作,甚至使用非英文键盘。我没有为插件使用任何特殊的代码或设置,就像 pub.dev 中提到的一样。我正在使用 Flutter channel stable v. 1.22.6

如果您需要,这是我的代码:


class WebViewerWidget extends StatefulWidget {
  final Map<String, String> metaData;

  WebViewerWidget({this.metaData});

  @override
  _WebViewerWidgetState createState() => _WebViewerWidgetState();
}

class _WebViewerWidgetState extends State<WebViewerWidget> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    InAppWebViewController _webviewCtrl;
    double progressIndicator = 0;
    return Scaffold(
        backgroundColor: ColorPalette.white,
        appBar: PreferredSize(
          child: TopNavWidget(
            title: widget.metaData['title'] ?? '',
          ),
          preferredSize: Size.fromHeight(50.0),
        ),
        body: Builder(
          builder: (BuildContext context) {
            return Container(
              child: Column(
                children: [
                  Container(
                      child: progressIndicator < 1
                          ? LinearProgressIndicator(
                              value: progressIndicator,
                              backgroundColor: Colors.black12,
                              valueColor:
                                  AlwaysStoppedAnimation<Color>(Colors.blue),
                            )
                          : Container()),
                  Expanded(
                    child: InAppWebView(
                      initialUrl: widget.metaData['url'] ?? 'about:blank',
                      initialOptions: InAppWebViewGroupOptions(
                        crossPlatform: InAppWebViewOptions(
                          debuggingEnabled: true,
                          javaScriptEnabled: true,
                          useShouldInterceptAjaxRequest: true,
                          useShouldInterceptFetchRequest: true,
                        ),
                        ios: IOSInAppWebViewOptions(),
                        android: AndroidInAppWebViewOptions(),
                      ),
                      onWebViewCreated:
                          (InAppWebViewController webviewController) {
                        _webviewCtrl = webviewController;
                      },
                      onProgressChanged:
                          (InAppWebViewController controller, int progress) {
                        setState(() {
                          progressIndicator = progress / 100;
                        });
                      },
                    ),
                  ),
                ],
              ),
            );
          },
        ));
  }
}

谢谢。

4

2 回答 2

0

好的,在花了几天时间解决这个问题之后,我不得不放弃这个问题。它绝对是插件的一个错误,发现有人在这里遇到了类似的问题https://github.com/pichillilorenzo/flutter_inappwebview/issues/560。然后我尝试了另一个名为 WebView 的插件https://pub.dev/packages/webview_flutter,它运行良好。

于 2021-03-03T00:23:43.723 回答
0

新版本已修复此问题5.0.0(现在最新版本为5.0.5+3):使用useHybridComposition: trueAndroid 特定的 webview 选项,所有与 Android 键盘相关的问题都已修复。

于 2021-03-04T10:24:33.637 回答