juliansteenbakker / mobile_scanner

A universal scanner for Flutter based on MLKit. Uses CameraX on Android and AVFoundation on iOS.
BSD 3-Clause "New" or "Revised" License
897 stars 514 forks source link

Camera does not read qrcodes sequentially #591

Open edrianbiagi opened 1 year ago

edrianbiagi commented 1 year ago

I check if the qrcode was read correctly. If it returns status 400, it displays the error message. The camera is still enabled, but it is not possible to read a new qrcode.

final scannerController = MobileScannerController(
formats: [BarcodeFormat.qrCode],
autoStart: true,
detectionSpeed: DetectionSpeed.normal,
);

I need to close the camera and open it again if I want to read a qrcode.

ftecnologiasistemas commented 1 year ago

Any news about this problem? This happens to me too! I can't read a qrcode sequentially

zlusch95 commented 1 year ago

I found a solution that did the trick for me.

I initialize the scannerController in Flutter's build method of the corresponding stateful Widget class, and not directly within the class as you pobably would. The problem I had was that I wanted to toggle the camera, i.e. the scanner, on and of by pressing a camera button. And once I turned the camera on and of and on again with the button at least for one time, the scanner did not scan again.

As a result, I re-initialize and, thus I kind of reset the scanner every time the state of the stateful widget changes as I press the camera toggle button. At least that's how I interpret it. Anyway, it solves the issue of not being able of scanning sequentially.

Give it a try if you like!