Skip to content

Commit 895c11c

Browse files
Merge pull request #36 from omnitrogen/feature_field_customization
Field customization
2 parents c3b3aa7 + 7bc10d6 commit 895c11c

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

example/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
android:icon="@mipmap/ic_launcher">
66
<activity
77
android:name=".MainActivity"
8+
android:exported="true"
89
android:launchMode="singleTop"
910
android:theme="@style/LaunchTheme"
1011
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"

example/lib/main.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ class MyHomePage extends StatelessWidget {
129129
],
130130
),
131131
const SizedBox(height: 15),
132+
FormBuilderImagePicker(
133+
name: 'fieldCustomization',
134+
decoration: const InputDecoration(labelText: 'Pick Photos'),
135+
previewAutoSizeWidth: true,
136+
fit: BoxFit.cover,
137+
backgroundColor: Colors.black54,
138+
iconColor: Colors.white,
139+
icon: Icons.ac_unit_rounded,
140+
),
132141
ElevatedButton(
133142
child: const Text('Submit'),
134143
onPressed: () {

lib/src/form_builder_image_picker.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,15 @@ class FormBuilderImagePicker extends FormBuilderField<List<dynamic>> {
4242
/// placeholder widget displayed when picking a new image
4343
final Widget? placeholderWidget;
4444

45+
/// Field icon
46+
final IconData? icon;
47+
48+
/// Field icon color
4549
final Color? iconColor;
4650

51+
/// Field background color
52+
final Color? backgroundColor;
53+
4754
/// Optional maximum height of image; see [ImagePicker].
4855
final double? maxHeight;
4956

@@ -113,7 +120,9 @@ class FormBuilderImagePicker extends FormBuilderField<List<dynamic>> {
113120
this.previewWidth = 130,
114121
this.previewHeight = 130,
115122
this.previewMargin,
123+
this.icon,
116124
this.iconColor,
125+
this.backgroundColor,
117126
this.maxHeight,
118127
this.maxWidth,
119128
this.imageQuality,
@@ -165,11 +174,11 @@ class FormBuilderImagePicker extends FormBuilderField<List<dynamic>> {
165174
)
166175
: Container(
167176
color: (state.enabled
168-
? iconColor ?? primaryColor
169-
: disabledColor)
170-
.withAlpha(50),
177+
? backgroundColor ??
178+
primaryColor.withAlpha(50)
179+
: disabledColor),
171180
child: Icon(
172-
Icons.camera_enhance,
181+
icon ?? Icons.camera_enhance,
173182
color: state.enabled
174183
? iconColor ?? primaryColor
175184
: disabledColor,

0 commit comments

Comments
 (0)