@@ -30,10 +30,15 @@ class CameraPicker extends StatefulWidget {
30
30
CameraPicker ({
31
31
Key key,
32
32
this .isAllowRecording = false ,
33
+ this .isOnlyAllowRecording = false ,
33
34
this .maximumRecordingDuration = const Duration (seconds: 15 ),
34
35
this .theme,
35
36
CameraPickerTextDelegate textDelegate,
36
- }) : super (key: key) {
37
+ }) : assert (
38
+ isAllowRecording == true || isOnlyAllowRecording != true ,
39
+ 'Recording mode error.' ,
40
+ ),
41
+ super (key: key) {
37
42
Constants .textDelegate = textDelegate ??
38
43
(isAllowRecording
39
44
? DefaultCameraPickerTextDelegateWithRecording ()
@@ -44,6 +49,10 @@ class CameraPicker extends StatefulWidget {
44
49
/// 选择器是否可以录像
45
50
final bool isAllowRecording;
46
51
52
+ /// Whether the picker can record video.
53
+ /// 选择器是否可以录像
54
+ final bool isOnlyAllowRecording;
55
+
47
56
/// The maximum duration of the video recording process.
48
57
/// 录制视频最长时长
49
58
///
@@ -60,17 +69,22 @@ class CameraPicker extends StatefulWidget {
60
69
static Future <AssetEntity > pickFromCamera (
61
70
BuildContext context, {
62
71
bool isAllowRecording = false ,
72
+ bool isOnlyAllowRecording = false ,
63
73
Duration maximumRecordingDuration = const Duration (seconds: 15 ),
64
74
ThemeData theme,
65
75
CameraPickerTextDelegate textDelegate,
66
76
}) async {
77
+ if (isAllowRecording != true && isOnlyAllowRecording == true ) {
78
+ throw ArgumentError ('Recording mode error.' );
79
+ }
67
80
final AssetEntity result = await Navigator .of (
68
81
context,
69
82
rootNavigator: true ,
70
83
).push <AssetEntity >(
71
84
SlidePageTransitionBuilder <AssetEntity >(
72
85
builder: CameraPicker (
73
86
isAllowRecording: isAllowRecording,
87
+ isOnlyAllowRecording: isOnlyAllowRecording,
74
88
theme: theme,
75
89
textDelegate: textDelegate,
76
90
),
@@ -193,6 +207,10 @@ class CameraPickerState extends State<CameraPicker> {
193
207
/// 选择器是否可以录像(非空包装)
194
208
bool get isAllowRecording => widget.isAllowRecording ?? false ;
195
209
210
+ /// Whether the picker can only record video. (A non-null wrapper)
211
+ /// 选择器是否仅可以录像(非空包装)
212
+ bool get isOnlyAllowRecording => widget.isOnlyAllowRecording ?? false ;
213
+
196
214
/// Getter for `widget.maximumRecordingDuration` .
197
215
Duration get maximumRecordingDuration => widget.maximumRecordingDuration;
198
216
@@ -597,7 +615,7 @@ class CameraPickerState extends State<CameraPicker> {
597
615
onPointerUp: isAllowRecording ? recordDetectionCancel : null ,
598
616
child: InkWell (
599
617
borderRadius: maxBorderRadius,
600
- onTap: takePicture,
618
+ onTap: ! isOnlyAllowRecording ? takePicture : null ,
601
619
onLongPress: isAllowRecording ? recordDetection : null ,
602
620
child: SizedBox .fromSize (
603
621
size: outerSize,
0 commit comments