diff --git a/CHANGELOG.md b/CHANGELOG.md index 810b36f8..eca54980 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ that can be found in the LICENSE file. --> - Allow flash modes failed to switch and can move on to next when switching. (#156) +### Fixes + +- Fix lifecycle integrations with the camera preview. (#157) + ## 3.6.5 ### Fixes diff --git a/lib/src/states/camera_picker_state.dart b/lib/src/states/camera_picker_state.dart index d5ab88c1..faf6fbf6 100644 --- a/lib/src/states/camera_picker_state.dart +++ b/lib/src/states/camera_picker_state.dart @@ -199,14 +199,14 @@ class CameraPickerState extends State @override void didChangeAppLifecycleState(AppLifecycleState state) { final CameraController? c = innerController; - // App state changed before we got the chance to initialize. - if (c == null || !c.value.isInitialized) { + if (state == AppLifecycleState.resumed) { + initCameras(currentCamera); + } else if (c == null || !c.value.isInitialized) { + // App state changed before we got the chance to initialize. return; - } - if (state == AppLifecycleState.inactive) { + } else if (state == AppLifecycleState.inactive) { c.dispose(); - } else if (state == AppLifecycleState.resumed) { - initCameras(currentCamera); + innerController = null; } }