Skip to content

Commit

Permalink
🐛 Fix lifecycle integrations with the camera preview. (#157)
Browse files Browse the repository at this point in the history
This proposed solution solved my issue on iPhone SE 2020 through
near-production installation through test-flight.

Co-authored-by: Alex Li <[email protected]>
  • Loading branch information
lcuis and AlexV525 authored Jan 16, 2023
1 parent ff0f6d3 commit 9e29888
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions lib/src/states/camera_picker_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ class CameraPickerState extends State<CameraPicker>
@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;
}
}

Expand Down

0 comments on commit 9e29888

Please sign in to comment.