diff --git a/example/lib/main.dart b/example/lib/main.dart index 74b5810..141be9d 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -50,7 +50,7 @@ class _MyHomePageState extends State { UnitechBarcodeScanner(), BlueBirdBarcodeScanner(), ZebraBarcodeScanner('my_profile'), - UsbKeyboardScanner(), + UsbKeyboardScanner(child: const SizedBox()), ]; @override diff --git a/packages/usb_keyboard_scanner/README.md b/packages/usb_keyboard_scanner/README.md index af3f2da..43697e3 100644 --- a/packages/usb_keyboard_scanner/README.md +++ b/packages/usb_keyboard_scanner/README.md @@ -18,6 +18,8 @@ BarcodeScannerWidget( configuration: const ScannerConfiguration( enableFormats: {}, // supported formats are determined by the scanner itself ), - scanners: [UsbKeyboardScanner()], + scanners: [UsbKeyboardScanner( + child: content, + )], ); ``` \ No newline at end of file diff --git a/packages/usb_keyboard_scanner/example/main.dart b/packages/usb_keyboard_scanner/example/main.dart index b92741a..236be1e 100644 --- a/packages/usb_keyboard_scanner/example/main.dart +++ b/packages/usb_keyboard_scanner/example/main.dart @@ -63,7 +63,9 @@ class _MyHomePageState extends State { configuration: const ScannerConfiguration( enableFormats: {}, // enableFormats unfortunately does not work with the UsbKeyboardScanner, this configuration is managed by the device itself ), - scanners: [UsbKeyboardScanner()], + scanners: [UsbKeyboardScanner( + child: const SizedBox(), + )], ), ); } diff --git a/packages/usb_keyboard_scanner/lib/src/usb_keyboard_scanner.dart b/packages/usb_keyboard_scanner/lib/src/usb_keyboard_scanner.dart index 4549071..5026159 100644 --- a/packages/usb_keyboard_scanner/lib/src/usb_keyboard_scanner.dart +++ b/packages/usb_keyboard_scanner/lib/src/usb_keyboard_scanner.dart @@ -8,7 +8,8 @@ import 'package:flutter/material.dart'; /// Please follow the installation instructions in /// [https://pub.dev/packages/fast_barcode_scanner] class UsbKeyboardScanner implements BarcodeScanner { - int maxCharacterInputIntervalMs; + final int maxCharacterInputIntervalMs; + final Widget child; late ValueChanged _onScan; late FocusNode _focusNode; @@ -17,7 +18,10 @@ class UsbKeyboardScanner implements BarcodeScanner { var isRunning = true; - UsbKeyboardScanner({this.maxCharacterInputIntervalMs = 50}); + UsbKeyboardScanner({ + this.maxCharacterInputIntervalMs = 50, + required this.child, + }); @override Widget? buildUI(ScannerConfiguration configuration, BuildContext context) => @@ -25,7 +29,7 @@ class UsbKeyboardScanner implements BarcodeScanner { focusNode: _focusNode, autofocus: true, onKeyEvent: _onKeyEvent, - child: const SizedBox(), + child: child, ); @override