From b7db23f490d05540b9971642a87419f00068fceb Mon Sep 17 00:00:00 2001 From: Alex Li Date: Mon, 23 Dec 2024 15:28:11 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Wrap=20controller=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/states/camera_picker_state.dart | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/src/states/camera_picker_state.dart b/lib/src/states/camera_picker_state.dart index c955fe2..a181276 100644 --- a/lib/src/states/camera_picker_state.dart +++ b/lib/src/states/camera_picker_state.dart @@ -945,15 +945,19 @@ class CameraPickerState extends State } wrapControllerMethod( 'setFocusMode', - () => controller.setFocusMode(FocusMode.auto), + () async { + await innerController?.setFocusMode(FocusMode.auto); + }, ); if (previousExposureMode != ExposureMode.locked) { wrapControllerMethod( 'setExposureMode', - () => controller.setExposureMode(previousExposureMode), + () async { + await innerController?.setExposureMode(previousExposureMode); + }, ); } - await controller.resumePreview(); + await innerController?.resumePreview(); } catch (e, s) { handleErrorWithHandler(e, s, pickerConfig.onError); } finally { @@ -1071,13 +1075,13 @@ class CameraPickerState extends State ); if (entity != null) { if (pickerConfig.onPickConfirmed case final onPickConfirmed?) { - await controller.resumePreview(); + await innerController?.resumePreview(); onPickConfirmed(entity); } else { Navigator.of(context).pop(entity); } } else { - await controller.resumePreview(); + await innerController?.resumePreview(); } } catch (e, s) { recordCountdownTimer?.cancel();