Auto Focus QR Scanner
Asked Answered
A

1

6

I am developing a flutter app that uses qr_code_scanner dependence(https://pub.dev/packages/qr_code_scanner).

I want the QrView to autofocus, but I can't find a solution. How do I auto focus the Camera for qr_code_scanner?

Assembler answered 2/7, 2021 at 15:16 Comment(2)
Has anyone found any solutions?Jeanninejeans
hello were you able to solve this?Cobia
M
0

It might be a little late man, but I managed to do it as follows.

When we set the cameraFacing property to CameraFacing.back, you start using the rear camera of the device, allowing the operating system to manage the camera's autofocus.

Therefore, if your device supports autofocus, it will adjust the focus automatically to try to capture the QR code more accurately.

You can make this small adjustment to your creation method by adding the following snippet at the end of the method:

void _onQRViewCreated(QRViewController controller) async {
// your code...
controller.flipCamera();
await Future.delayed(const Duration(milliseconds: 400));
controller.flipCamera();
}

A small delay is added with Future.delayed() to allow the camera to adjust before flipping it again!

Mouldy answered 7/5, 2023 at 17:49 Comment(1)
I appreciate your response. Although I no longer use this dependence, your answer should help someone else in need.Assembler

© 2022 - 2025 — McMap. All rights reserved.