diff --git a/CHANGELOG.md b/CHANGELOG.md index d00b4ca..b92d639 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ See the [Migration Guide](guides/migration_guide.md) for breaking changes betwee ### Fixes - Fix preview file delete predication. +- Avoid potential null operations when saving the entity. ## 4.3.3 diff --git a/lib/src/states/camera_picker_state.dart b/lib/src/states/camera_picker_state.dart index 3c5bca8..1144aad 100644 --- a/lib/src/states/camera_picker_state.dart +++ b/lib/src/states/camera_picker_state.dart @@ -966,15 +966,19 @@ class CameraPickerState extends State } wrapControllerMethod( 'setFocusMode', - () => controller.setFocusMode(FocusMode.auto), + () async { + await innerController?.setFocusMode(FocusMode.auto); + }, ); if (previousExposureMode != ExposureMode.locked) { wrapControllerMethod( 'setExposureMode', - () => controller.setExposureMode(previousExposureMode), + () async { + await innerController?.setExposureMode(previousExposureMode); + }, ); } - await controller.resumePreview(); + await innerController?.resumePreview(); } catch (e, s) { handleErrorWithHandler(e, s, pickerConfig.onError); } finally { @@ -1092,13 +1096,13 @@ class CameraPickerState extends State ); if (entity != null) { if (pickerConfig.onPickConfirmed case final onPickConfirmed?) { - await controller.resumePreview(); + await innerController?.resumePreview(); onPickConfirmed(entity); } else { Navigator.of(context).pop(entity); } } else { - await controller.resumePreview(); + await innerController?.resumePreview(); } } catch (e, s) { recordCountdownTimer?.cancel();