Closed eduardotq closed 4 years ago
I've also encountered this problem. You can enforce intervals between scans by transforming the stream, I'm pretty new to reactive programming but it does work as intended.
subscription = FlutterBarcodeScanner.getBarcodeStreamReceiver(
'#FF0000',
'CLOSE',
true,
ScanMode.BARCODE,
).transform(
StreamTransformer.fromHandlers(
handleData: (data, sink) {
if (timer == null) {
sink.add(data);
// Set desirable interval in Duration.
timer = Timer(Duration(seconds: 1), () {
timer = null;
});
}
},
),
).listen((barcode) {
if ((barcode ?? '').isEmpty || barcode == '-1') {
subscription.cancel();
return;
}
// Do something with barcode
});
I'm a newbie programmer, so I had no ideia how to solve this problem.. Thank you very much!
Would be a good idea to close the issue if it's resolved for you. Cheers!
Sorry, I forgot
Thank you for solution. It's work very well 👍🏾
Hi, would have some possibility to set a cooldown time in the continuous scan? It's because when I'm using it, sometime it scans too fast and register the same barcode more than one time. If you could set some cooldown time, would be nice. Thank you!