@@ -28,18 +28,18 @@ const Duration _kRouteDuration = Duration(milliseconds: 300);
28
28
class CameraPicker extends StatefulWidget {
29
29
CameraPicker ({
30
30
Key key,
31
- this .isAllowPinchToZoom = true ,
32
- this .isAllowRecording = false ,
33
- this .isOnlyAllowRecording = false ,
31
+ this .allowRecording = false ,
32
+ this .onlyAllowRecording = false ,
34
33
this .enableAudio = true ,
34
+ this .enablePinchToZoom = true ,
35
35
this .maximumRecordingDuration = const Duration (seconds: 15 ),
36
36
this .theme,
37
37
this .resolutionPreset = ResolutionPreset .max,
38
38
this .cameraQuarterTurns = 0 ,
39
39
this .foregroundBuilder,
40
40
CameraPickerTextDelegate textDelegate,
41
41
}) : assert (
42
- isAllowRecording == true || isOnlyAllowRecording != true ,
42
+ allowRecording == true || onlyAllowRecording != true ,
43
43
'Recording mode error.' ,
44
44
),
45
45
assert (
@@ -48,7 +48,7 @@ class CameraPicker extends StatefulWidget {
48
48
),
49
49
super (key: key) {
50
50
Constants .textDelegate = textDelegate ??
51
- (isAllowRecording
51
+ (allowRecording
52
52
? DefaultCameraPickerTextDelegateWithRecording ()
53
53
: DefaultCameraPickerTextDelegate ());
54
54
}
@@ -57,22 +57,22 @@ class CameraPicker extends StatefulWidget {
57
57
/// 摄像机视图顺时针旋转次数,每次90度
58
58
final int cameraQuarterTurns;
59
59
60
- /// Whether users can zoom the camera by pinch.
61
- /// 用户是否可以在界面上双指缩放相机对焦
62
- final bool isAllowPinchToZoom;
63
-
64
60
/// Whether the picker can record video.
65
61
/// 选择器是否可以录像
66
- final bool isAllowRecording ;
62
+ final bool allowRecording ;
67
63
68
64
/// Whether the picker can record video.
69
65
/// 选择器是否可以录像
70
- final bool isOnlyAllowRecording ;
66
+ final bool onlyAllowRecording ;
71
67
72
68
/// Whether the picker should record audio.
73
69
/// 选择器录像时是否需要录制声音
74
70
final bool enableAudio;
75
71
72
+ /// Whether users can zoom the camera by pinch.
73
+ /// 用户是否可以在界面上双指缩放相机对焦
74
+ final bool enablePinchToZoom;
75
+
76
76
/// The maximum duration of the video recording process.
77
77
/// 录制视频最长时长
78
78
///
@@ -96,9 +96,9 @@ class CameraPicker extends StatefulWidget {
96
96
/// 通过相机创建 [AssetEntity] 的静态方法
97
97
static Future <AssetEntity > pickFromCamera (
98
98
BuildContext context, {
99
- bool isAllowPinchToZoom = true ,
100
- bool isAllowRecording = false ,
101
- bool isOnlyAllowRecording = false ,
99
+ bool allowPinchToZoom = true ,
100
+ bool allowRecording = false ,
101
+ bool onlyAllowRecording = false ,
102
102
bool enableAudio = true ,
103
103
Duration maximumRecordingDuration = const Duration (seconds: 15 ),
104
104
ThemeData theme,
@@ -107,7 +107,7 @@ class CameraPicker extends StatefulWidget {
107
107
ResolutionPreset resolutionPreset = ResolutionPreset .max,
108
108
Widget Function (CameraValue ) foregroundBuilder,
109
109
}) async {
110
- if (isAllowRecording != true && isOnlyAllowRecording == true ) {
110
+ if (allowRecording != true && onlyAllowRecording == true ) {
111
111
throw ArgumentError ('Recording mode error.' );
112
112
}
113
113
if (resolutionPreset == null ) {
@@ -119,9 +119,9 @@ class CameraPicker extends StatefulWidget {
119
119
).push <AssetEntity >(
120
120
SlidePageTransitionBuilder <AssetEntity >(
121
121
builder: CameraPicker (
122
- isAllowPinchToZoom : isAllowPinchToZoom ,
123
- isAllowRecording : isAllowRecording ,
124
- isOnlyAllowRecording : isOnlyAllowRecording ,
122
+ enablePinchToZoom : allowPinchToZoom ,
123
+ allowRecording : allowRecording ,
124
+ onlyAllowRecording : onlyAllowRecording ,
125
125
enableAudio: enableAudio,
126
126
maximumRecordingDuration: maximumRecordingDuration,
127
127
theme: theme,
@@ -273,22 +273,22 @@ class CameraPickerState extends State<CameraPicker>
273
273
274
274
/// Whether users can zoom the camera by pinch. (A non-null wrapper)
275
275
/// 用户是否可以在界面上双指缩放相机对焦(非空包装)
276
- bool get isAllowPinchToZoom => widget.isAllowPinchToZoom ?? true ;
276
+ bool get allowPinchToZoom => widget.enablePinchToZoom ?? true ;
277
277
278
278
/// Whether the picker can record video. (A non-null wrapper)
279
279
/// 选择器是否可以录像(非空包装)
280
- bool get isAllowRecording => widget.isAllowRecording ?? false ;
280
+ bool get allowRecording => widget.allowRecording ?? false ;
281
281
282
282
/// Whether the picker can only record video. (A non-null wrapper)
283
283
/// 选择器是否仅可以录像(非空包装)
284
- bool get isOnlyAllowRecording => widget.isOnlyAllowRecording ?? false ;
284
+ bool get onlyAllowRecording => widget.onlyAllowRecording ?? false ;
285
285
286
286
/// Whether the picker should record audio. (A non-null wrapper)
287
287
/// 选择器录制视频时,是否需要录制音频(非空包装)
288
288
///
289
289
/// No audio integration required when it's only for camera.
290
290
/// 在仅允许拍照时不需要启用音频
291
- bool get enableAudio => isAllowRecording && (widget.enableAudio ?? true );
291
+ bool get enableAudio => allowRecording && (widget.enableAudio ?? true );
292
292
293
293
/// Getter for `widget.maximumRecordingDuration` .
294
294
Duration get maximumRecordingDuration => widget.maximumRecordingDuration;
@@ -742,11 +742,11 @@ class CameraPickerState extends State<CameraPicker>
742
742
final Size outerSize = Size .square (Screens .width / 3.5 );
743
743
return Listener (
744
744
behavior: HitTestBehavior .opaque,
745
- onPointerUp: isAllowRecording ? recordDetectionCancel : null ,
745
+ onPointerUp: allowRecording ? recordDetectionCancel : null ,
746
746
child: InkWell (
747
747
borderRadius: maxBorderRadius,
748
- onTap: ! isOnlyAllowRecording ? takePicture : null ,
749
- onLongPress: isAllowRecording ? recordDetection : null ,
748
+ onTap: ! onlyAllowRecording ? takePicture : null ,
749
+ onLongPress: allowRecording ? recordDetection : null ,
750
750
child: SizedBox .fromSize (
751
751
size: outerSize,
752
752
child: Stack (
@@ -866,9 +866,10 @@ class CameraPickerState extends State<CameraPicker>
866
866
onPointerDown: (_) => _pointers++ ,
867
867
onPointerUp: (_) => _pointers-- ,
868
868
child: GestureDetector (
869
- onScaleStart: isAllowPinchToZoom ? _handleScaleStart : null ,
870
- onScaleUpdate: isAllowPinchToZoom ? _handleScaleUpdate : null ,
871
- onDoubleTap: switchCameras,
869
+ onScaleStart: allowPinchToZoom ? _handleScaleStart : null ,
870
+ onScaleUpdate: allowPinchToZoom ? _handleScaleUpdate : null ,
871
+ // Enabled cameras switching by default if we have multiple cameras.
872
+ onDoubleTap: cameras.length > 1 ? switchCameras : null ,
872
873
child: CameraPreview (controller),
873
874
),
874
875
);
0 commit comments