@@ -29,6 +29,7 @@ class CameraPicker extends StatefulWidget {
29
29
Key key,
30
30
this .shouldKeptInLocal = false ,
31
31
this .isAllowRecording = false ,
32
+ this .maximumRecordingDuration = const Duration (seconds: 15 ),
32
33
this .theme,
33
34
CameraPickerTextDelegate textDelegate,
34
35
}) : super (key: key) {
@@ -43,6 +44,15 @@ class CameraPicker extends StatefulWidget {
43
44
/// 选择器是否可以录像
44
45
final bool isAllowRecording;
45
46
47
+ /// The maximum duration of the video recording process.
48
+ /// 录制视频最长时长
49
+ ///
50
+ /// This is 15 seconds by default.
51
+ /// Also allow `null` for unrestricted video recording.
52
+ final Duration maximumRecordingDuration;
53
+
54
+ /// Theme data for the picker.
55
+ /// 选择器的主题
46
56
final ThemeData theme;
47
57
48
58
/// Static method to create [AssetEntity] through camera.
@@ -51,6 +61,7 @@ class CameraPicker extends StatefulWidget {
51
61
BuildContext context, {
52
62
bool shouldKeptInLocal = false ,
53
63
bool isAllowRecording = false ,
64
+ Duration maximumRecordingDuration = const Duration (seconds: 15 ),
54
65
ThemeData theme,
55
66
CameraPickerTextDelegate textDelegate,
56
67
}) async {
@@ -174,6 +185,14 @@ class CameraPickerState extends State<CameraPicker> {
174
185
/// 选择器是否可以录像(非空包装)
175
186
bool get isAllowRecording => widget.isAllowRecording ?? false ;
176
187
188
+ /// Whether the recording restricted to a specific duration.
189
+ /// 录像是否有限制的时长
190
+ ///
191
+ /// It's **NON-GUARANTEE** for stability if there's no limitation on the record duration.
192
+ /// This is still an experimental control.
193
+ /// 如果拍摄时长没有限制,不保证稳定性。它仍然是一项实验性的控制。
194
+ bool get isRecordingRestricted => widget.maximumRecordingDuration != null ;
195
+
177
196
/// The path of the taken picture file.
178
197
/// 拍照文件的路径
179
198
String takenPictureFilePath;
@@ -194,9 +213,6 @@ class CameraPickerState extends State<CameraPicker> {
194
213
/// 获取当前相机实例
195
214
CameraDescription get currentCamera => cameras? .elementAt (currentCameraIndex);
196
215
197
- /// Theme data for the picker.
198
- /// 选择器的主题
199
- ///
200
216
/// If there's no theme provided from the user, use [CameraPicker.themeData] .
201
217
/// 如果用户未提供主题,
202
218
ThemeData _theme;
@@ -411,9 +427,7 @@ class CameraPickerState extends State<CameraPicker> {
411
427
child: Row (
412
428
children: < Widget > [
413
429
Expanded (
414
- child: ! isRecording
415
- ? Center (child: backButton)
416
- : const SizedBox .shrink (),
430
+ child: ! isRecording ? Center (child: backButton) : const SizedBox .shrink (),
417
431
),
418
432
Expanded (child: Center (child: shootingButton)),
419
433
const Spacer (),
0 commit comments