Open navaronbracke opened 1 month ago
Hi,
@navaronbracke Thanks.
My current implementation is like that (using the streamSubscription
)
Option1 is using the cancel
function
Option2 is using the resume
, pause
function
Option2 is better since we can use the isPause
property.
I think it would be nice if the same behavior we be built in.
void startListenToScannerCapture() {
streamSubscriptionScanner = controller.barcodes.listen(scannerlistener);
}
void scannerlistener(BarcodeCapture barcodeCapture) async {
Some actions
.
.
.
.
//option1:
await streamSubscription.cancel();
//option2:
// setState(() {
// streamSubscriptionScanner.pause();
// });
}
// And when button pressed
onPressed: () {
//option1:
startListenToScannerCapture();
//option2:
// setState(() {
// streamSubscriptionScanner.resume();
// });
},
@navaronbracke
Note:
By the way, regarding option 2 -
There is something weird regarding the StreamSubscription<BarcodeCapture>
,
streamSubscriptionScanner = controller.barcodes.listen(scannerlistenerCallback);
When I call: streamSubscription.pause()
And move the scanner on a barcode, it doesn't read it, which is ok.
But when I call streamSubscription.resume()
,
the stream listener callback is called with the scanned value of the barcode that was scanned while I was on pause.
version: 5.0.0-beta.2
@navaronbracke
Hi, Any update on the issue here?
Thanks.
No, not yet. Although there is an open PR, but that is to pause the camera preview, not the barcode scanner.
No, not yet. Although there is an open PR, but that is to pause the camera preview, not the barcode scanner.
Ok thanks. But when you are going to work on it, pay attention to my additional comment: https://github.com/juliansteenbakker/mobile_scanner/issues/1006#issuecomment-2049613983
We should clear the scanned barcodes in the scanner itself when resuming. We only do that for the start method currently.
A user requested a way to be able to stop the scanner, while the camera preview is still open and providing video input.
This issue serves as a feature request for that.
When resuming the subscription, the old barcode results should be cleared.