I'm developing a Flutter app that will end up running on an Android based scanning device. As with many hardware scanners, the device rapidly fires a number of keyboard events upon scanning a barcode. I've resorted to a Flutter package that seemed ideal for my usecase: https://pub.dev/packages/flutter_barcode_listener - Basically all this does is listen for RawKeyEvents using Flutter's built-in RawKeyboard class, translate those to usable characters, fill an array with those characters and upon receiving a linefeed (\n), join the array into a string and return it.
This works fine until a soft keyboard is opened within the app, as soon as this has happened the only RawKeyEvent the listener receives after scanning a barcode is a linefeed and nothing else. As a result an empty string is returned after scanning a barcode. Weirdly enough, causing the app to lose focus (e.g. by minimizing it with the home button or opening the recent app overview) will restore functionality to the barcode listener, and the proper RawKeyEvents will be generated once more.
This is definitely an issue on Flutter's end, as I confirmed the scanner still reads out data through ADB logging. Any pointers as to what may be causing this are very welcome.
I'd also like to add that ADB logging tells me the following after scanning a barcode:
3104 9582 D ScanDataOutput: softkeyboard is not running (2)
3104 9582 D ScanDataOutput: SSI(terminator):<LF>
3104 9582 D ScanDataOutput: LF, 4
3104 9582 E ScanDataOutput: ERROR! terminator = <LF>!
3104 9582 E ScanDataOutput: ERROR! terminator :
3104 9582 E ScanDataOutput: dataResult: