File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -460,13 +460,17 @@ class CameraPickerState extends State<CameraPicker>
460
460
461
461
@override
462
462
void didChangeAppLifecycleState (AppLifecycleState state) {
463
+ final CameraController ? c = _controller;
463
464
// App state changed before we got the chance to initialize.
464
- if (_controller == null || ! controller .value.isInitialized) {
465
+ if (c == null || ! c .value.isInitialized) {
465
466
return ;
466
467
}
467
468
if (state == AppLifecycleState .inactive) {
468
- controller.dispose ();
469
- } else if (state == AppLifecycleState .resumed) {
469
+ c.dispose ();
470
+ } else if (state == AppLifecycleState .resumed && ! c.value.isInitialized) {
471
+ // Drop initialize when the controller has been already initialized.
472
+ // This will typically resolve the lifecycle issue on iOS when permissions
473
+ // are requested for the first time.
470
474
initCameras (currentCamera);
471
475
}
472
476
}
You can’t perform that action at this time.
0 commit comments