@@ -369,6 +369,8 @@ class CameraPickerState extends State<CameraPicker>
369
369
/// 通过常量全局 Key 获取当前选择器的主题
370
370
ThemeData get theme => _theme;
371
371
372
+ bool _isPreparedForIOSRecording = false ;
373
+
372
374
@override
373
375
void initState () {
374
376
super .initState ();
@@ -783,8 +785,12 @@ class CameraPickerState extends State<CameraPicker>
783
785
784
786
/// Set record file path and start recording.
785
787
/// 设置拍摄文件路径并开始录制视频
786
- void startRecordingVideo () {
788
+ Future < void > startRecordingVideo () async {
787
789
if (! controller.value.isRecordingVideo) {
790
+ if (! _isPreparedForIOSRecording) {
791
+ await controller.prepareForVideoRecording ();
792
+ _isPreparedForIOSRecording = true ;
793
+ }
788
794
controller.startVideoRecording ().then ((dynamic _) {
789
795
safeSetState (() {});
790
796
if (isRecordingRestricted) {
@@ -986,9 +992,6 @@ class CameraPickerState extends State<CameraPicker>
986
992
const Size innerSize = Size .square (82 );
987
993
return Listener (
988
994
behavior: HitTestBehavior .opaque,
989
- onPointerDown: shouldPrepareForVideoRecording
990
- ? (_) => controller.prepareForVideoRecording ()
991
- : null ,
992
995
onPointerUp: enableRecording ? recordDetectionCancel : null ,
993
996
onPointerMove: enablePullToZoomInRecord
994
997
? (PointerMoveEvent e) => onShootingButtonMove (e, constraints)
0 commit comments