我想在所有情况下隐藏键盘
我正在制作条形码扫描应用程序,并且也将此应用程序也用于手持端子终端。如果用户按下手终端上的读取键,则将返回值填充到文本字段中。我希望看不到这一点,并阻止键盘在其他情况下重新打开。我该怎么做?
为了清楚:我专注于文本字段,并在手终端上使用条形码读取键分配一个值,但我不希望键盘出现在屏幕上。有什么办法可以做到吗?
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将focusnode()实例分配到文本字段,并在on Changed中调用focusnode.unfocus()
You need to assign a FocusNode() instance to your text field and call focusNode.unfocus() inside onChanged