首页 > 解决方案 > 有没有办法连接到安卓设备的激光扫描仪?

问题描述

公司给了我这个安卓设备 https://i.stack.imgur.com/SLGfy.jpg

有没有办法从颤振应用程序调用内置扫描仪?设备有一个硬件密钥可以随时激活扫描仪,我想在我的颤振应用程序中扫描条形码

标签: flutterdart

解决方案


RawKeyboardListener(
        onKey: (key) {
          if (key.runtimeType.toString() == 'RawKeyDownEvent') {


              appState.barcodeTxt.text += key.data.keyLabel;

              if (appState.barcodeTxt.text.contains('\n')) {
               // your custom `enter key` fun
                appState.switchKeypadListioner(context, 'enter');
              }
            }
          }
        },
        focusNode: appState.barcodeFocusNode,
        child: TextField(
          textInputAction: TextInputAction.go,
           controller: appState.barcodeTxt,
          autofocus: false,
           onSubmitted: (val) {
           // enter key handler
            appState.switchKeypadListioner(context, 'enter');

          },
          keyboardType: TextInputType.number,


        ),
      )

推荐阅读