1
1
import 'package:flutter/material.dart' ;
2
2
import 'package:flutter_form_builder/flutter_form_builder.dart' ;
3
3
import 'package:flutter_form_builder/src/widgets/image_source_sheet.dart' ;
4
+ import 'package:image_picker/image_picker.dart' ;
4
5
5
6
class FormBuilderImagePicker extends StatefulWidget {
6
7
final String attribute;
@@ -19,6 +20,23 @@ class FormBuilderImagePicker extends StatefulWidget {
19
20
final EdgeInsets imageMargin;
20
21
final Color iconColor;
21
22
23
+ /// Optional maximum height of image; see [ImagePicker] .
24
+ final double maxHeight;
25
+
26
+ /// Optional maximum width of image; see [ImagePicker] .
27
+ final double maxWidth;
28
+
29
+ /// The imageQuality argument modifies the quality of the image, ranging from
30
+ /// 0-100 where 100 is the original/max quality. If imageQuality is null, the
31
+ /// image with the original quality will be returned. See [ImagePicker] .
32
+ final int imageQuality;
33
+
34
+ /// Use preferredCameraDevice to specify the camera to use when the source is
35
+ /// `ImageSource.camera` . The preferredCameraDevice is ignored when source is
36
+ /// `ImageSource.gallery` . It is also ignored if the chosen camera is not
37
+ /// supported on the device. Defaults to `CameraDevice.rear` . See [ImagePicker] .
38
+ final CameraDevice preferredCameraDevice;
39
+
22
40
const FormBuilderImagePicker ({
23
41
Key key,
24
42
@required this .attribute,
@@ -34,6 +52,10 @@ class FormBuilderImagePicker extends StatefulWidget {
34
52
this .onSaved,
35
53
this .decoration = const InputDecoration (),
36
54
this .iconColor,
55
+ this .maxHeight,
56
+ this .maxWidth,
57
+ this .imageQuality,
58
+ this .preferredCameraDevice = CameraDevice .rear,
37
59
}) : super (key: key);
38
60
39
61
@override
@@ -161,6 +183,11 @@ class _FormBuilderImagePickerState extends State<FormBuilderImagePicker> {
161
183
context: context,
162
184
builder: (_) {
163
185
return ImageSourceSheet (
186
+ maxHeight: widget.maxHeight,
187
+ maxWidth: widget.maxWidth,
188
+ imageQuality: widget.imageQuality,
189
+ preferredCameraDevice:
190
+ widget.preferredCameraDevice,
164
191
onImageSelected: (image) {
165
192
field.didChange (
166
193
[...field.value, image]);
0 commit comments