【问题标题】:Flutter InAppWebView does not allow non english content in textfieldFlutter InAppWebView 不允许文本字段中包含非英文内容
【发布时间】:2021-05-30 01:07:54
【问题描述】:

我在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;
                        });
                      },
                    ),
                  ),
                ],
              ),
            );
          },
        ));
  }
}

谢谢。

【问题讨论】:

  • 好的,现在我注意到当我忽略表单上的第一个文本字段时它会开始工作,在这种情况下是用户的全名,直接跳到下一个文本字段是电子邮件,在这里输入一些东西然后回到用户全名,这次它允许我输入越南字符。太奇怪了。

标签: flutter flutter-inappwebview


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 谢谢@Lorenzo。会再试一次。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-11
    • 1970-01-01
    • 2013-10-06
    • 1970-01-01
    • 2011-01-25
    • 2019-02-10
    • 2021-09-10
    相关资源
    最近更新 更多