From c12cfb16976b69c19affc4f802852c936741f845 Mon Sep 17 00:00:00 2001 From: Vadim Date: Thu, 3 Aug 2023 22:46:01 +0200 Subject: [PATCH] Lock & release focus when taking a picture --- .../components/camera_container/bloc_container_camera.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/screens/metering/components/camera_container/bloc_container_camera.dart b/lib/screens/metering/components/camera_container/bloc_container_camera.dart index fee9899..9c8658d 100644 --- a/lib/screens/metering/components/camera_container/bloc_container_camera.dart +++ b/lib/screens/metering/components/camera_container/bloc_container_camera.dart @@ -129,7 +129,6 @@ class CameraContainerBloc extends EvSourceBlocBase([ _cameraController!.getMinZoomLevel(), @@ -206,7 +205,13 @@ class CameraContainerBloc extends EvSourceBlocBase _takePhoto() async { try { + // https://github.com/flutter/flutter/issues/84957#issuecomment-1661155095 + await _cameraController!.setFocusMode(FocusMode.locked); + await _cameraController!.setExposureMode(ExposureMode.locked); final file = await _cameraController!.takePicture(); + await _cameraController!.setFocusMode(FocusMode.auto); + await _cameraController!.setExposureMode(ExposureMode.auto); + final Uint8List bytes = await file.readAsBytes(); Directory(file.path).deleteSync(recursive: true);