Peripheral Keyboard and Barcode Scanner with Flutter
Peripheral Keyboard and Barcode Scanner
The project demonstrates how to turn a Flutter mobile app into a peripheral keyboard and barcode scanner to input data into PCs.
Setting Up the Python Server
-
Install pyautogui, websockets and zeroconf using pip:
pip install pyautogui websockets zeroconf
-
Change the port numbers for Bonjour service and web socket server if they are already in use.
# Bonjour info = ServiceInfo("_bonsoirdemo._tcp.local.", "Python Web Socket Server._bonsoirdemo._tcp.local.", port=7000, addresses=[ip_address]) # Web Socket Server s = await websockets.serve(server, ip_address, 4000)
If you change the web socket port in the server, you also need to change the port in the Flutter app.
_connect('${widget.service.ip}:4000');
-
Run the server:
python server.py
Setting Up the Flutter Mobile App
-
Apply for a trial license key of Dynamsoft Barcode Reader SDK from here.
-
Replace the license key in the
scanner_screen.dart
file.await DCVBarcodeReader.initLicense( 'DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==');
-
Run the app on your mobile device.
flutter run