@@ -693,9 +693,13 @@ class CameraPickerState extends State<CameraPicker>
693
693
final ExposureMode previousExposureMode = controller.value.exposureMode;
694
694
try {
695
695
await Future .wait (< Future <void >> [
696
- controller.setFocusMode (FocusMode .locked),
696
+ controller.setFocusMode (FocusMode .locked).catchError ((e, s) {
697
+ handleErrorWithHandler (e, pickerConfig.onError, s: s);
698
+ }),
697
699
if (previousExposureMode != ExposureMode .locked)
698
- controller.setExposureMode (ExposureMode .locked),
700
+ controller.setExposureMode (ExposureMode .locked).catchError ((e, s) {
701
+ handleErrorWithHandler (e, pickerConfig.onError, s: s);
702
+ }),
699
703
]);
700
704
final XFile file = await controller.takePicture ();
701
705
await controller.pausePreview ();
@@ -720,9 +724,8 @@ class CameraPickerState extends State<CameraPicker>
720
724
controller.setExposureMode (previousExposureMode),
721
725
]);
722
726
await controller.resumePreview ();
723
- } catch (e) {
724
- realDebugPrint ('Error when preview the captured file: $e ' );
725
- handleErrorWithHandler (e, pickerConfig.onError);
727
+ } catch (e, s) {
728
+ handleErrorWithHandler (e, pickerConfig.onError, s: s);
726
729
} finally {
727
730
isControllerBusy = false ;
728
731
safeSetState (() {});
@@ -784,17 +787,13 @@ class CameraPickerState extends State<CameraPicker>
784
787
..start ();
785
788
} catch (e, s) {
786
789
isControllerBusy = false ;
787
- realDebugPrint ('Error when start recording video: $e ' );
788
790
if (! controller.value.isRecordingVideo) {
789
791
handleErrorWithHandler (e, pickerConfig.onError, s: s);
790
792
return ;
791
793
}
792
794
try {
793
795
await controller.stopVideoRecording ();
794
796
} catch (e, s) {
795
- realDebugPrint (
796
- 'Error when stop recording video after an error start: $e ' ,
797
- );
798
797
recordCountdownTimer? .cancel ();
799
798
isShootingButtonAnimate = false ;
800
799
handleErrorWithHandler (e, pickerConfig.onError, s: s);
@@ -846,11 +845,9 @@ class CameraPickerState extends State<CameraPicker>
846
845
await controller.resumePreview ();
847
846
}
848
847
} catch (e, s) {
849
- realDebugPrint ('Error when stop recording video: $e ' );
850
- realDebugPrint ('Try to initialize a new CameraController...' );
851
- initCameras ();
852
- handleError ();
853
848
handleErrorWithHandler (e, pickerConfig.onError, s: s);
849
+ handleError ();
850
+ initCameras ();
854
851
} finally {
855
852
isControllerBusy = false ;
856
853
safeSetState (() {});
0 commit comments