@@ -654,15 +654,9 @@ class CameraPickerState extends State<CameraPicker>
654654 _controller = null ;
655655 });
656656 });
657- final AssetEntity ? entity = await CameraPickerViewer .pushToViewer (
658- context,
659- pickerState: this ,
660- pickerType: CameraPickerViewType .image,
661- previewXFile: _file,
662- theme: theme,
663- shouldDeletePreviewFile: shouldDeletePreviewFile,
664- shouldAutoPreviewVideo: shouldAutoPreviewVideo,
665- onEntitySaving: config.onEntitySaving,
657+ final AssetEntity ? entity = await _pushToViewer (
658+ file: _file,
659+ viewType: CameraPickerViewType .image,
666660 );
667661 if (entity != null ) {
668662 Navigator .of (context).pop (entity);
@@ -748,14 +742,9 @@ class CameraPickerState extends State<CameraPicker>
748742
749743 if (controller.value.isRecordingVideo) {
750744 controller.stopVideoRecording ().then ((XFile file) async {
751- final AssetEntity ? entity = await CameraPickerViewer .pushToViewer (
752- context,
753- pickerState: this ,
754- pickerType: CameraPickerViewType .video,
755- previewXFile: file,
756- theme: theme,
757- shouldDeletePreviewFile: shouldDeletePreviewFile,
758- shouldAutoPreviewVideo: shouldAutoPreviewVideo,
745+ final AssetEntity ? entity = await _pushToViewer (
746+ file: file,
747+ viewType: CameraPickerViewType .video,
759748 );
760749 if (entity != null ) {
761750 Navigator .of (context).pop (entity);
@@ -775,6 +764,23 @@ class CameraPickerState extends State<CameraPicker>
775764 _handleError ();
776765 }
777766
767+ Future <AssetEntity ?> _pushToViewer ({
768+ required XFile file,
769+ required CameraPickerViewType viewType,
770+ }) {
771+ return CameraPickerViewer .pushToViewer (
772+ context,
773+ pickerState: this ,
774+ pickerType: viewType,
775+ previewXFile: file,
776+ theme: theme,
777+ shouldDeletePreviewFile: shouldDeletePreviewFile,
778+ shouldAutoPreviewVideo: shouldAutoPreviewVideo,
779+ onEntitySaving: config.onEntitySaving,
780+ onError: config.onError,
781+ );
782+ }
783+
778784 ////////////////////////////////////////////////////////////////////////////
779785 ////////////////////////////////////////////////////////////////////////////
780786 /////////////////////////// Just a line breaker ////////////////////////////
0 commit comments