From 2a5a64c2a1bb7eb108d914c4f1256a4b292a1805 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 21 Aug 2024 10:39:55 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Nullable=20camera=20description?= =?UTF-8?q?=20Fixes=20#261?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/states/camera_picker_state.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/states/camera_picker_state.dart b/lib/src/states/camera_picker_state.dart index 6b51d53..88e0720 100644 --- a/lib/src/states/camera_picker_state.dart +++ b/lib/src/states/camera_picker_state.dart @@ -43,7 +43,7 @@ class CameraPickerState extends State /// Available cameras. /// 可用的相机实例 - late List cameras; + List cameras = []; /// Whether the controller is handling method calls. /// 相机控制器是否在处理方法调用 @@ -270,7 +270,9 @@ class CameraPickerState extends State void didChangeAppLifecycleState(AppLifecycleState state) { final CameraController? c = innerController; if (state == AppLifecycleState.resumed && !accessDenied) { - initCameras(cameraDescription: currentCamera); + initCameras( + cameraDescription: cameras.elementAtOrNull(currentCameraIndex), + ); } else if (c == null || !c.value.isInitialized) { // App state changed before we got the chance to initialize. return;