File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -681,20 +681,26 @@ class CameraPickerState extends State<CameraPicker>
681
681
/// 仅当初始化成功且相机未在拍照时拍照。
682
682
Future <void > takePicture () async {
683
683
if (controller.value.isInitialized && ! controller.value.isTakingPicture) {
684
+ final XFile _file = await controller.takePicture ();
685
+ // Delay disposing the controller to hold the preview.
686
+ Future <void >.delayed (const Duration (milliseconds: 500 ), () {
687
+ controller.dispose ();
688
+ });
684
689
final AssetEntity ? entity = await CameraPickerViewer .pushToViewer (
685
690
context,
686
691
pickerState: this ,
687
692
pickerType: CameraPickerViewType .image,
688
- previewXFile: await controller. takePicture () ,
693
+ previewXFile: _file ,
689
694
theme: theme,
690
695
shouldDeletePreviewFile: shouldDeletePreviewFile,
691
696
onEntitySaving: widget.onEntitySaving,
692
697
);
693
698
if (entity != null ) {
694
699
Navigator .of (context).pop (entity);
695
- } else {
696
- safeSetState (() {});
700
+ return ;
697
701
}
702
+ initCameras (currentCamera);
703
+ safeSetState (() {});
698
704
}
699
705
}
700
706
You can’t perform that action at this time.
0 commit comments