Skip to content

Commit 63ca84d

Browse files
committed
2 parents a519cb9 + cc36448 commit 63ca84d

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

lib/src/fields/form_builder_image_picker.dart

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class FormBuilderImagePicker extends StatefulWidget {
3939
final CameraDevice preferredCameraDevice;
4040

4141
final int maxImages;
42-
42+
final String defaultImage;
4343
final Widget cameraIcon;
4444
final Widget galleryIcon;
4545
final Widget cameraLabel;
@@ -50,6 +50,7 @@ class FormBuilderImagePicker extends StatefulWidget {
5050
Key key,
5151
@required this.attribute,
5252
this.initialValue,
53+
this.defaultImage,
5354
this.validators = const [],
5455
this.valueTransformer,
5556
this.labelText,
@@ -88,7 +89,7 @@ class _FormBuilderImagePickerState extends State<FormBuilderImagePicker> {
8889
return false;
8990
} else {
9091
return /*_fieldKey.currentState.value != null &&*/ _fieldKey
91-
.currentState.value.length >=
92+
.currentState.value.length >=
9293
widget.maxImages;
9394
}
9495
}
@@ -160,8 +161,8 @@ class _FormBuilderImagePickerState extends State<FormBuilderImagePicker> {
160161
child: kIsWeb
161162
? Image.memory(item, fit: BoxFit.cover)
162163
: 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),
165166
),
166167
if (!_readOnly)
167168
InkWell(
@@ -190,17 +191,24 @@ class _FormBuilderImagePickerState extends State<FormBuilderImagePicker> {
190191
}).toList()),
191192
if (!_readOnly && !_hasMaxImages)
192193
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+
),
204212
onTap: () {
205213
showModalBottomSheet(
206214
context: context,
@@ -210,7 +218,7 @@ class _FormBuilderImagePickerState extends State<FormBuilderImagePicker> {
210218
maxWidth: widget.maxWidth,
211219
imageQuality: widget.imageQuality,
212220
preferredCameraDevice:
213-
widget.preferredCameraDevice,
221+
widget.preferredCameraDevice,
214222
cameraIcon: widget.cameraIcon,
215223
galleryIcon: widget.galleryIcon,
216224
cameraLabel: widget.cameraLabel,

0 commit comments

Comments
 (0)