Skip to content

Commit 1731cc3

Browse files
committed
⚡ Update constructor.
1 parent 5c1668d commit 1731cc3

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

lib/src/widget/camera_picker.dart

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class CameraPicker extends StatefulWidget {
2929
Key key,
3030
this.shouldKeptInLocal = false,
3131
this.isAllowRecording = false,
32+
this.maximumRecordingDuration = const Duration(seconds: 15),
3233
this.theme,
3334
CameraPickerTextDelegate textDelegate,
3435
}) : super(key: key) {
@@ -43,6 +44,15 @@ class CameraPicker extends StatefulWidget {
4344
/// 选择器是否可以录像
4445
final bool isAllowRecording;
4546

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+
/// 选择器的主题
4656
final ThemeData theme;
4757

4858
/// Static method to create [AssetEntity] through camera.
@@ -51,6 +61,7 @@ class CameraPicker extends StatefulWidget {
5161
BuildContext context, {
5262
bool shouldKeptInLocal = false,
5363
bool isAllowRecording = false,
64+
Duration maximumRecordingDuration = const Duration(seconds: 15),
5465
ThemeData theme,
5566
CameraPickerTextDelegate textDelegate,
5667
}) async {
@@ -174,6 +185,14 @@ class CameraPickerState extends State<CameraPicker> {
174185
/// 选择器是否可以录像(非空包装)
175186
bool get isAllowRecording => widget.isAllowRecording ?? false;
176187

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+
177196
/// The path of the taken picture file.
178197
/// 拍照文件的路径
179198
String takenPictureFilePath;
@@ -194,9 +213,6 @@ class CameraPickerState extends State<CameraPicker> {
194213
/// 获取当前相机实例
195214
CameraDescription get currentCamera => cameras?.elementAt(currentCameraIndex);
196215

197-
/// Theme data for the picker.
198-
/// 选择器的主题
199-
///
200216
/// If there's no theme provided from the user, use [CameraPicker.themeData] .
201217
/// 如果用户未提供主题,
202218
ThemeData _theme;
@@ -411,9 +427,7 @@ class CameraPickerState extends State<CameraPicker> {
411427
child: Row(
412428
children: <Widget>[
413429
Expanded(
414-
child: !isRecording
415-
? Center(child: backButton)
416-
: const SizedBox.shrink(),
430+
child: !isRecording ? Center(child: backButton) : const SizedBox.shrink(),
417431
),
418432
Expanded(child: Center(child: shootingButton)),
419433
const Spacer(),

0 commit comments

Comments
 (0)