我想在所有情况下隐藏键盘

发布于 2025-02-03 18:36:07 字数 671 浏览 3 评论 0原文

我正在制作条形码扫描应用程序,并且也将此应用程序也用于手持端子终端。如果用户按下手终端上的读取键,则将返回值填充到文本字段中。我希望看不到这一点,并阻止键盘在其他情况下重新打开。我该怎么做?

为了清楚:我专注于文本字段,并在手终端上使用条形码读取键分配一个值,但我不希望键盘出现在屏幕上。有什么办法可以做到吗?

Container(
        height: 0,
        width: 0,
        child: TextField(
          autofocus: true,
          controller: editingController,
          onChanged: (val) {
            setState(() {
              value = editingController.text;
            });
            SystemChannels.textInput.invokeMethod("TextInput.hide");
            print(editingController.text);
            editingController.clear();
            print(value + "aaa");
          },
        ),
      ),

I am making a barcode scanning application and I am making this application to work on handheld terminals as well. If the user presses the read key on the hand terminal, the return value will be filled into the textfield. I want to not see this and prevent the keyboard from reopening in other setState situations. How can I do that?

For clarity: I focus on the textfield and assign a value with the barcode reading key on the hand terminal, but I don't want the keyboard to appear on the screen. Is there a way I can do this?

Container(
        height: 0,
        width: 0,
        child: TextField(
          autofocus: true,
          controller: editingController,
          onChanged: (val) {
            setState(() {
              value = editingController.text;
            });
            SystemChannels.textInput.invokeMethod("TextInput.hide");
            print(editingController.text);
            editingController.clear();
            print(value + "aaa");
          },
        ),
      ),

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笨死的猪 2025-02-10 18:36:07

您需要将focusnode()实例分配到文本字段,并在on Changed中调用focusnode.unfocus()

You need to assign a FocusNode() instance to your text field and call focusNode.unfocus() inside onChanged

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文