Closed kaboc closed 1 year ago
Here is a log that was printed in the console when a QR code was scanned.
I/flutter ( 4417): onScan
I/Camera ( 4417): startPreview
I/Camera ( 4417): CameraCaptureSession onConfigured
I/Camera ( 4417): Updating builder settings
D/Camera ( 4417): Updating builder with feature: ExposureLockFeature
D/Camera ( 4417): Updating builder with feature: ExposurePointFeature
D/Camera ( 4417): Updating builder with feature: ZoomLevelFeature
D/Camera ( 4417): Updating builder with feature: AutoFocusFeature
D/Camera ( 4417): Updating builder with feature: NoiseReductionFeature
I/Camera ( 4417): updateNoiseReduction | currentSetting: fast
D/Camera ( 4417): Updating builder with feature: FocusPointFeature
D/Camera ( 4417): Updating builder with feature: ResolutionFeature
D/Camera ( 4417): Updating builder with feature: SensorOrientationFeature
D/Camera ( 4417): Updating builder with feature: FlashFeature
D/Camera ( 4417): Updating builder with feature: ExposureOffsetFeature
D/Camera ( 4417): Updating builder with feature: FpsRangeFeature
I/Camera ( 4417): refreshPreviewCaptureSession
I/Camera ( 4417): CameraCaptureSession onClosed
I/Camera ( 4417): dispose
I/Camera ( 4417): close
I/Camera ( 4417): open | onClosed
The first line is a print call I added before stopImageStream()
in the onScan
callback.
onScan: (code) async {
print('onScan');
await _controller?.stopImageStream();
setState(() => _text = code.text);
},
It seems strange that "startPreview" appears when the image stream is stopped.
Thank you for bringing these issues to my attention. I really appreciate the time you took to report this and for helping me improve. I'll be sure to take a look and get back to you as soon as possible.
Best regards, Khoren
Hi there,
I just wanted to let you know that I have updated the example in the repository. Could you please take a look and see if everything is working as expected?
Thank you!
@khoren93
I'm sorry if my explanation was unclear. I actually don't know if there was anything wrong in the example of the package itself. The issue is about the strange behaviour that the scan result remains and triggers the onScan
callback immediately next time if stopImageStream()
is used when scanning is successful. I didn't mean the example in the repository should be improved, but it is great that the example is better now.
Hi @kaboc
In my case, I have not experienced duplicate calls with the scan callback when using flutter_zxing, so I would not recommend using stopImageStream()
.
Below is an example app to demonstrate the issue.
onScan
callback is called. In the callback:stopImageStream()
is called._text
.onScan
is called immediately and the result view is shown. (This is wrong!)onScan
is not called this time.I used
stopImageStream()
because I had experienced duplicate calls to the scan callback in another plugin. I'm not sure if it can happen with flutter_zxing too, but I wanted to make sureonScan()
was called only once.I don't think it is a critical issue, but it took me hours to figure out that
stopImageStream()
was causing it, and I still have no idea why it is wrong to use it there. I feel that something is wrong in the package and it is better that the issue is fixed so that other developers won't experience it.