@@ -31,6 +31,7 @@ class CameraPicker extends StatefulWidget {
31
31
Key key,
32
32
this .isAllowRecording = false ,
33
33
this .isOnlyAllowRecording = false ,
34
+ this .enableAudio = true ,
34
35
this .maximumRecordingDuration = const Duration (seconds: 15 ),
35
36
this .theme,
36
37
this .resolutionPreset = ResolutionPreset .max,
@@ -63,6 +64,10 @@ class CameraPicker extends StatefulWidget {
63
64
/// 选择器是否可以录像
64
65
final bool isOnlyAllowRecording;
65
66
67
+ /// Whether the picker should record audio.
68
+ /// 选择器录像时是否需要录制声音
69
+ final bool enableAudio;
70
+
66
71
/// The maximum duration of the video recording process.
67
72
/// 录制视频最长时长
68
73
///
@@ -84,6 +89,7 @@ class CameraPicker extends StatefulWidget {
84
89
BuildContext context, {
85
90
bool isAllowRecording = false ,
86
91
bool isOnlyAllowRecording = false ,
92
+ bool enableAudio = true ,
87
93
Duration maximumRecordingDuration = const Duration (seconds: 15 ),
88
94
ThemeData theme,
89
95
int cameraQuarterTurns = 0 ,
@@ -104,6 +110,7 @@ class CameraPicker extends StatefulWidget {
104
110
builder: CameraPicker (
105
111
isAllowRecording: isAllowRecording,
106
112
isOnlyAllowRecording: isOnlyAllowRecording,
113
+ enableAudio: enableAudio,
107
114
maximumRecordingDuration: maximumRecordingDuration,
108
115
theme: theme,
109
116
cameraQuarterTurns: cameraQuarterTurns,
@@ -233,6 +240,10 @@ class CameraPickerState extends State<CameraPicker> {
233
240
/// 选择器是否仅可以录像(非空包装)
234
241
bool get isOnlyAllowRecording => widget.isOnlyAllowRecording ?? false ;
235
242
243
+ /// Whether the picker should record audio. (A non-null wrapper)
244
+ /// 选择器录制视频时,是否需要录制音频(非空包装)
245
+ bool get enableAudio => isAllowRecording && (widget.enableAudio ?? true );
246
+
236
247
/// Getter for `widget.maximumRecordingDuration` .
237
248
Duration get maximumRecordingDuration => widget.maximumRecordingDuration;
238
249
@@ -371,6 +382,7 @@ class CameraPickerState extends State<CameraPicker> {
371
382
cameraController = CameraController (
372
383
cameraDescription ?? cameras[0 ],
373
384
widget.resolutionPreset,
385
+ enableAudio: enableAudio,
374
386
);
375
387
cameraController.initialize ().then ((dynamic _) {
376
388
if (mounted) {
0 commit comments