@@ -575,13 +575,7 @@ class CameraPickerState extends State<CameraPicker>
575
575
}
576
576
try {
577
577
final XFile file = await controller.takePicture ();
578
- // Delay disposing the controller to hold the preview.
579
- Future <void >.delayed (const Duration (milliseconds: 500 ), () {
580
- innerController? .dispose ();
581
- safeSetState (() {
582
- innerController = null ;
583
- });
584
- });
578
+ await controller.pausePreview ();
585
579
final bool ? isCapturedFileHandled = pickerConfig.onXFileCaptured? .call (
586
580
file,
587
581
CameraPickerViewType .image,
@@ -597,11 +591,12 @@ class CameraPickerState extends State<CameraPicker>
597
591
Navigator .of (context).pop (entity);
598
592
return ;
599
593
}
600
- initCameras (currentCamera);
601
- safeSetState (() {});
594
+ await controller.resumePreview ();
602
595
} catch (e) {
603
596
realDebugPrint ('Error when preview the captured file: $e ' );
604
597
handleErrorWithHandler (e, pickerConfig.onError);
598
+ } finally {
599
+ safeSetState (() {});
605
600
}
606
601
}
607
602
@@ -688,8 +683,12 @@ class CameraPickerState extends State<CameraPicker>
688
683
handleError ();
689
684
return ;
690
685
}
686
+ safeSetState (() {
687
+ isShootingButtonAnimate = false ;
688
+ });
691
689
try {
692
690
final XFile file = await controller.stopVideoRecording ();
691
+ await controller.pausePreview ();
693
692
final bool ? isCapturedFileHandled = pickerConfig.onXFileCaptured? .call (
694
693
file,
695
694
CameraPickerViewType .video,
@@ -703,6 +702,8 @@ class CameraPickerState extends State<CameraPicker>
703
702
);
704
703
if (entity != null ) {
705
704
Navigator .of (context).pop (entity);
705
+ } else {
706
+ await controller.resumePreview ();
706
707
}
707
708
} catch (e, s) {
708
709
realDebugPrint ('Error when stop recording video: $e ' );
@@ -711,7 +712,6 @@ class CameraPickerState extends State<CameraPicker>
711
712
handleError ();
712
713
handleErrorWithHandler (e, pickerConfig.onError, s: s);
713
714
} finally {
714
- isShootingButtonAnimate = false ;
715
715
safeSetState (() {});
716
716
}
717
717
}
@@ -991,6 +991,7 @@ class CameraPickerState extends State<CameraPicker>
991
991
if ((innerController? .value.isRecordingVideo ?? false ) &&
992
992
isRecordingRestricted)
993
993
CameraProgressButton (
994
+ isAnimating: isShootingButtonAnimate,
994
995
duration: pickerConfig.maximumRecordingDuration! ,
995
996
outerRadius: outerSize.width,
996
997
ringsColor: theme.indicatorColor,
0 commit comments