Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller.pause doesn't stop the scanning of barcode #1331

Open
AliYar-Khan opened this issue Feb 16, 2025 · 3 comments
Open

Controller.pause doesn't stop the scanning of barcode #1331

AliYar-Khan opened this issue Feb 16, 2025 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@AliYar-Khan
Copy link

I am trying to pause the scanning of barcodes once it detects a barcode

  MobileScanner(
     controller: controller,
     onDetect: (capture) {
           final List<Barcode> barcodes = capture.barcodes;
           if (barcodes.isNotEmpty) {
               controller.pause();
               getProduct(barcodes.first.rawValue);
           }
      },
 ),

But it doesn't stop scanning and keep reading barcode

controller.pause() should stop scanning I make the code await and use .then as well but nothing seems to work

@navaronbracke
Copy link
Collaborator

The pause method only pauses the camera preview iirc. What if you pause the stream subscription for the barcode stream?

@AliYar-Khan
Copy link
Author

@navaronbracke how to pause the stream ?

@navaronbracke
Copy link
Collaborator

navaronbracke commented Feb 20, 2025

I see that you are using onDetect. You can manually listen to the barcodes stream of the controller and pause the StreamSubscription that you get from that.

Although, maybe we should also pause the underlying stream source when pause() is called for the camera preview.

@navaronbracke navaronbracke self-assigned this Feb 20, 2025
@navaronbracke navaronbracke added the bug Something isn't working label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants