Closed burekas7 closed 1 month ago
It seems that the controller has that: controller.start(), controller.stop() I will check it.
In the new beta release, you have full control over the scanner lifecycle. So this is already possible.
@navaronbracke Thanks. But if I get it right, the way to do that is what I mentioned, right? (start/stop)
Yes, that is the way to use the API.
@navaronbracke
But when I call the stop()
it turns off the camera.
My purpose is only stopping the scanning action, not the camera.
Actually, I need an option to close/start the Stream<BarcodeCapture>
In that case, we should handle pausing and resuming the StreamSubscription
in mobile_scanner
.
@navaronbracke Thanks.
Currently I implemented this local solution: It works. But yes, it could be nice to do this via controller or something like that.
void startListenToScannerCapture() {
streamSubscription = controller.barcodes.listen(scannerlistener);
}
void scannerlistener(BarcodeCapture barcodeCapture) async {
Some actions
.
.
.
.
await streamSubscription.cancel();
}
// And when button pressed
onPressed: () {
startListenToScannerCapture();
},
@navaronbracke
There is something weird here,
When I do: streamSubscription.pause()
And I move the scanner on a barcode, it doesn't read it, which is ok.
But when I streamSubscription.resume()
,
the stream listener callback is run with a scan value of the barcode while I was on pause.
Is it a bug?
That could definitely be a bug related to pause / resume of the subscription
@navaronbracke Ok thanks, I will open a new issue for that.
=> https://github.com/juliansteenbakker/mobile_scanner/issues/1008
@burekas7 No need for that, I added a note in https://github.com/juliansteenbakker/mobile_scanner/issues/1006
@navaronbracke Ok, so I closed #1008 and also added it as a comment in #1006
Hi,
I want to have control over when the scanner will start scanning and when it will stop. How can this be done?
Currently the scanner starts scanning immediately when the screen comes up.