@@ -39,7 +39,7 @@ class FormBuilderImagePicker extends StatefulWidget {
39
39
final CameraDevice preferredCameraDevice;
40
40
41
41
final int maxImages;
42
-
42
+ final String defaultImage;
43
43
final Widget cameraIcon;
44
44
final Widget galleryIcon;
45
45
final Widget cameraLabel;
@@ -50,6 +50,7 @@ class FormBuilderImagePicker extends StatefulWidget {
50
50
Key key,
51
51
@required this .attribute,
52
52
this .initialValue,
53
+ this .defaultImage,
53
54
this .validators = const [],
54
55
this .valueTransformer,
55
56
this .labelText,
@@ -88,7 +89,7 @@ class _FormBuilderImagePickerState extends State<FormBuilderImagePicker> {
88
89
return false ;
89
90
} else {
90
91
return /*_fieldKey.currentState.value != null &&*/ _fieldKey
91
- .currentState.value.length >=
92
+ .currentState.value.length >=
92
93
widget.maxImages;
93
94
}
94
95
}
@@ -160,8 +161,8 @@ class _FormBuilderImagePickerState extends State<FormBuilderImagePicker> {
160
161
child: kIsWeb
161
162
? Image .memory (item, fit: BoxFit .cover)
162
163
: item is String
163
- ? Image .network (item, fit: BoxFit .cover)
164
- : Image .file (item, fit: BoxFit .cover),
164
+ ? Image .network (item, fit: BoxFit .cover)
165
+ : Image .file (item, fit: BoxFit .cover),
165
166
),
166
167
if (! _readOnly)
167
168
InkWell (
@@ -190,17 +191,24 @@ class _FormBuilderImagePickerState extends State<FormBuilderImagePicker> {
190
191
}).toList ()),
191
192
if (! _readOnly && ! _hasMaxImages)
192
193
GestureDetector (
193
- child: Container (
194
- width: widget.imageWidth,
195
- height: widget.imageHeight,
196
- child: Icon (Icons .camera_enhance,
197
- color: _readOnly
198
- ? theme.disabledColor
199
- : widget.iconColor ?? theme.primaryColor),
200
- color: (_readOnly
201
- ? theme.disabledColor
202
- : widget.iconColor ?? theme.primaryColor)
203
- .withAlpha (50 )),
194
+ child: widget.defaultImage != null ?
195
+ Image (
196
+ width: widget.imageWidth,
197
+ height: widget.imageHeight,
198
+ image: AssetImage (widget.defaultImage),
199
+ ): Container (
200
+ width: widget.imageWidth,
201
+ height: widget.imageHeight,
202
+ child: Icon (Icons .camera_enhance,
203
+ color: _readOnly
204
+ ? theme.disabledColor
205
+ : widget.iconColor ?? theme.primaryColor
206
+ ),
207
+ color: (_readOnly
208
+ ? theme.disabledColor
209
+ : widget.iconColor ?? theme.primaryColor)
210
+ .withAlpha (50 ),
211
+ ),
204
212
onTap: () {
205
213
showModalBottomSheet (
206
214
context: context,
@@ -210,7 +218,7 @@ class _FormBuilderImagePickerState extends State<FormBuilderImagePicker> {
210
218
maxWidth: widget.maxWidth,
211
219
imageQuality: widget.imageQuality,
212
220
preferredCameraDevice:
213
- widget.preferredCameraDevice,
221
+ widget.preferredCameraDevice,
214
222
cameraIcon: widget.cameraIcon,
215
223
galleryIcon: widget.galleryIcon,
216
224
cameraLabel: widget.cameraLabel,
0 commit comments