颤振支持中的外部键盘 [英] External keyboard in flutter support
本文介绍了颤振支持中的外部键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在没有文本字段的情况下从外部键盘收集字符并将其追加到变量中? 我正在尝试将蓝牙/USB条码扫描器设置为在扫描时自动进行扫描,但不必单击某个字段(或查看一个字段) 并拥有一个信用卡读取器,可在后台自动执行所有操作.
How can I collect chars from external keyboard and append to a var without having a text field? Im trying to setup a Bluetooth/USB barcode scanner to automatically to something when scanned but not that you have to click a field (or see one) And have a credit card reader Automatically do everything in the background..
推荐答案
RawKeyboardListener
允许执行 https://docs.flutter.io/flutter/widgets/RawKeyboardListener-class.html
var _focusNode = FocusNode();
@override
Widget build(BuildContext context) {
return RawKeyboardListener(
child: Text('raw keyboard input'),
focusNode: _focusNode,
onKey: _onRawKeyEvent,
);
}
void _onRawKeyEvent(RawKeyEvent event) {
..
}
这篇关于颤振支持中的外部键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文