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

  1. Install pyautogui, websockets and zeroconf using pip:

    pip install pyautogui websockets zeroconf
  2. 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');
  3. Run the server:

    python server.py

Setting Up the Flutter Mobile App

  1. Apply for a trial license key of Dynamsoft Barcode Reader SDK from here.

  2. Replace the license key in the scanner_screen.dart file.

    await DCVBarcodeReader.initLicense(
          'DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==');
  3. Run the app on your mobile device.

    flutter run

GitHub

View Github