Skip to content

Commit 9e29888

Browse files
lcuisAlexV525
andauthored
🐛 Fix lifecycle integrations with the camera preview. (#157)
This proposed solution solved my issue on iPhone SE 2020 through near-production installation through test-flight. Co-authored-by: Alex Li <[email protected]>
1 parent ff0f6d3 commit 9e29888

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ that can be found in the LICENSE file. -->
1414

1515
- Allow flash modes failed to switch and can move on to next when switching. (#156)
1616

17+
### Fixes
18+
19+
- Fix lifecycle integrations with the camera preview. (#157)
20+
1721
## 3.6.5
1822

1923
### Fixes

lib/src/states/camera_picker_state.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,14 @@ class CameraPickerState extends State<CameraPicker>
199199
@override
200200
void didChangeAppLifecycleState(AppLifecycleState state) {
201201
final CameraController? c = innerController;
202-
// App state changed before we got the chance to initialize.
203-
if (c == null || !c.value.isInitialized) {
202+
if (state == AppLifecycleState.resumed) {
203+
initCameras(currentCamera);
204+
} else if (c == null || !c.value.isInitialized) {
205+
// App state changed before we got the chance to initialize.
204206
return;
205-
}
206-
if (state == AppLifecycleState.inactive) {
207+
} else if (state == AppLifecycleState.inactive) {
207208
c.dispose();
208-
} else if (state == AppLifecycleState.resumed) {
209-
initCameras(currentCamera);
209+
innerController = null;
210210
}
211211
}
212212

0 commit comments

Comments
 (0)