Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

External keyboard in flutter support

Tags:

flutter

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..

like image 608
RawSlugs Avatar asked Jan 01 '23 10:01

RawSlugs


1 Answers

RawKeyboardListener allows to do that 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) {
    ..
  }
like image 109
Günter Zöchbauer Avatar answered Feb 07 '23 14:02

Günter Zöchbauer