I'm using this code to listen what my Zebra TC25 read.
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
class ScanReader extends HookWidget {
const ScanReader({super.key});
@override
Widget build(BuildContext context) {
useEffect(() {
thisHandle(KeyEvent keyEvent) {
print(keyEvent);
return true;
}
HardwareKeyboard.instance.addHandler(thisHandle);
return () {
HardwareKeyboard.instance.removeHandler(thisHandle);
};
}, []);
return const Text("Zebra scan listener");
}
}
The problem is my function thisHandle
is never trigger. Why ?
To listen for KeyEvent
send by Datawedge in Zebra you need to Send characters as events
, as described here: https://developer.zebra.com/blog/listening-keypress-events-datawedge
It is also recommended to send TAB
and ENTER
events as described here: https://supportcommunity.zebra.com/s/article/DataWedge-for-Android-Send-Enter-or-Tab-after-scanning?language=en_US
This way your function thisHandle
should be triggered.