@@ -33,11 +33,16 @@ class CameraPicker extends StatefulWidget {
33
33
this .isOnlyAllowRecording = false ,
34
34
this .maximumRecordingDuration = const Duration (seconds: 15 ),
35
35
this .theme,
36
+ this .resolutionPreset = ResolutionPreset .max,
36
37
CameraPickerTextDelegate textDelegate,
37
38
}) : assert (
38
39
isAllowRecording == true || isOnlyAllowRecording != true ,
39
40
'Recording mode error.' ,
40
41
),
42
+ assert (
43
+ resolutionPreset != null ,
44
+ 'Resolution preset must not be null.' ,
45
+ ),
41
46
super (key: key) {
42
47
Constants .textDelegate = textDelegate ??
43
48
(isAllowRecording
@@ -64,6 +69,10 @@ class CameraPicker extends StatefulWidget {
64
69
/// 选择器的主题
65
70
final ThemeData theme;
66
71
72
+ /// Present resolution for the camera.
73
+ /// 相机的分辨率预设
74
+ final ResolutionPreset resolutionPreset;
75
+
67
76
/// Static method to create [AssetEntity] through camera.
68
77
/// 通过相机创建 [AssetEntity] 的静态方法
69
78
static Future <AssetEntity > pickFromCamera (
@@ -73,10 +82,14 @@ class CameraPicker extends StatefulWidget {
73
82
Duration maximumRecordingDuration = const Duration (seconds: 15 ),
74
83
ThemeData theme,
75
84
CameraPickerTextDelegate textDelegate,
85
+ ResolutionPreset resolutionPreset = ResolutionPreset .max,
76
86
}) async {
77
87
if (isAllowRecording != true && isOnlyAllowRecording == true ) {
78
88
throw ArgumentError ('Recording mode error.' );
79
89
}
90
+ if (resolutionPreset == null ) {
91
+ throw ArgumentError ('Resolution preset must not be null.' );
92
+ }
80
93
final AssetEntity result = await Navigator .of (
81
94
context,
82
95
rootNavigator: true ,
@@ -87,6 +100,7 @@ class CameraPicker extends StatefulWidget {
87
100
isOnlyAllowRecording: isOnlyAllowRecording,
88
101
theme: theme,
89
102
textDelegate: textDelegate,
103
+ resolutionPreset: resolutionPreset,
90
104
),
91
105
transitionCurve: Curves .easeIn,
92
106
transitionDuration: const Duration (milliseconds: 300 ),
@@ -348,7 +362,7 @@ class CameraPickerState extends State<CameraPicker> {
348
362
/// - No one want the lower resolutions. :)
349
363
cameraController = CameraController (
350
364
cameraDescription ?? cameras[0 ],
351
- ResolutionPreset .max ,
365
+ widget.resolutionPreset ,
352
366
);
353
367
cameraController.initialize ().then ((dynamic _) {
354
368
if (mounted) {
0 commit comments