Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class _MyHomePageState extends State<MyHomePage> {
UnitechBarcodeScanner(),
BlueBirdBarcodeScanner(),
ZebraBarcodeScanner('my_profile'),
UsbKeyboardScanner(),
UsbKeyboardScanner(child: const SizedBox()),
];

@override
Expand Down
4 changes: 3 additions & 1 deletion packages/usb_keyboard_scanner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ BarcodeScannerWidget(
configuration: const ScannerConfiguration(
enableFormats: {}, // supported formats are determined by the scanner itself
),
scanners: [UsbKeyboardScanner()],
scanners: [UsbKeyboardScanner(
child: content,
)],
);
```
4 changes: 3 additions & 1 deletion packages/usb_keyboard_scanner/example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ class _MyHomePageState extends State<MyHomePage> {
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(),
)],
),
);
}
Expand Down
10 changes: 7 additions & 3 deletions packages/usb_keyboard_scanner/lib/src/usb_keyboard_scanner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<BarcodeScanResult> _onScan;
late FocusNode _focusNode;
Expand All @@ -17,15 +18,18 @@ 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) =>
KeyboardListener(
focusNode: _focusNode,
autofocus: true,
onKeyEvent: _onKeyEvent,
child: const SizedBox(),
child: child,
);

@override
Expand Down