简体   繁体   English

硬件键在 Flutter 上显示屏幕键盘

[英]Hardware key shows on-screen keyboard on Flutter

I discovered a strange behaviour in Flutter.我在 Flutter 中发现了一个奇怪的行为。 I have a Zebra PDA with Android, and so I have an hardware keyboard on the device.我有一个带 Android 的 Zebra PDA,所以我在设备上有一个硬件键盘。 If I press an hardware key on the device keyboard, the on-screen keyboard shows up, and I don't think that is supposed to happen.如果我按下设备键盘上的硬件键,屏幕键盘会出现,但我认为这不应该发生。 After some investigation, I found out that this happen as soon as I show a widget with a TextField on it.经过一番调查,我发现只要我显示一个带有TextField的小部件,就会发生这种情况。 After the first time the on-screen keyboard appears, every time I press an hardware key the on-screen keyboard appears.在第一次出现屏幕键盘后,每次我按下硬件键时都会出现屏幕键盘。 This is very frustrating, because if I use hardware keys of course I don't need the on-screen keyboard.这非常令人沮丧,因为如果我使用硬件键,我当然不需要屏幕键盘。 I don't really understand if this is an expected behaviour and, if so, how can I avoid it.我真的不明白这是否是预期的行为,如果是,我该如何避免。

This doesn't seem to be an issue with Flutter, but rather on the device that you're using.这似乎不是 Flutter 的问题,而是您使用的设备的问题。 If the device displays the softkeyboard on hardware keyboard key presses, it's likely that you need to have the softkeyboard disabled on the device's Settings.如果设备在硬件键盘按键时显示软键盘,则您可能需要在设备的设置中禁用软键盘。

On stock Android Settings, it's under System > Languages & input > Physical keyboard .在库存 Android 设置中,它位于System > Languages & input > Physical keyboard Then toggle 'Show virtual keyboard'然后切换“显示虚拟键盘”

I've also tried setting TextField keyboardType to null to see if it can forcefully disable the softkeyboard, but doing so just shows the default softkeyboard.我还尝试将TextField keyboardType 设置为 null 以查看它是否可以强制禁用软键盘,但这样做只会显示默认的软键盘。

TextField(
  keyboardType: null
),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM