@@ -66,6 +66,8 @@ class FormBuilderColorPickerField extends FormBuilderField<Color> {
66
66
final bool enableInteractiveSelection;
67
67
final InputCounterWidgetBuilder ? buildCounter;
68
68
69
+ final Widget Function (Color ? )? colorPreviewBuilder;
70
+
69
71
FormBuilderColorPickerField ({
70
72
Key ? key,
71
73
//From Super
@@ -109,6 +111,7 @@ class FormBuilderColorPickerField extends FormBuilderField<Color> {
109
111
this .enableInteractiveSelection = true ,
110
112
this .buildCounter,
111
113
this .controller,
114
+ this .colorPreviewBuilder,
112
115
}) : super (
113
116
key: key,
114
117
initialValue: initialValue,
@@ -127,23 +130,19 @@ class FormBuilderColorPickerField extends FormBuilderField<Color> {
127
130
return TextField (
128
131
style: style,
129
132
decoration: state.decoration.copyWith (
130
- suffixIcon: LayoutBuilder (
131
- key: ObjectKey (state.value),
132
- builder: (context, constraints) {
133
- return Container (
134
- key: ObjectKey (state.value),
135
- height: constraints.minHeight,
136
- width: constraints.minHeight,
137
- decoration: BoxDecoration (
138
- color: state.value,
139
- shape: BoxShape .circle,
140
- border: Border .all (
141
- color: Colors .black,
142
- ),
133
+ suffixIcon: colorPreviewBuilder != null
134
+ ? colorPreviewBuilder (field.value)
135
+ : LayoutBuilder (
136
+ key: ObjectKey (state.value),
137
+ builder: (context, constraints) {
138
+ return Icon (
139
+ Icons .circle,
140
+ key: ObjectKey (state.value),
141
+ size: constraints.minHeight,
142
+ color: state.value,
143
+ );
144
+ },
143
145
),
144
- );
145
- },
146
- ),
147
146
),
148
147
enabled: state.enabled,
149
148
readOnly: readOnly,
0 commit comments