Skip to content

Commit ade7769

Browse files
committed
Released v4.0.0-alpha.9
1 parent 1c2ef7a commit ade7769

10 files changed

+82
-45
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [4.0.0-alpha.9] - 05-Aug-2020
2+
* Improved programmatically changing field values. Multiple fields can be updated once
3+
* Fix conversion to double error in `FormBuilderRating`
4+
* Removed redundant `FormBuilderRadioList` and `FormBuilderCheckboxList` fields
5+
* Other minor fixes from v3 commits
6+
17
## [4.0.0-alpha.8] - 23-Jul-2020
28
* Fixed erratic keyboard behavior on `FormBuilderTextField`
39
* Added documentation for `FormBuilder` & `FormBuilderField` attributes

README.md

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Column(
2121
child: Column(
2222
children: <Widget>[
2323
FormBuilderFilterChip(
24-
attribute: 'filter_chip',
24+
name: 'filter_chip',
2525
decoration: InputDecoration(
2626
labelText: 'Select many options',
2727
),
@@ -39,7 +39,7 @@ Column(
3939
],
4040
),
4141
FormBuilderChoiceChip(
42-
attribute: 'choice_chip',
42+
name: 'choice_chip',
4343
decoration: InputDecoration(
4444
labelText: 'Select an option',
4545
),
@@ -57,14 +57,14 @@ Column(
5757
],
5858
),
5959
FormBuilderColorPickerField(
60-
attribute: 'color_picker',
60+
name: 'color_picker',
6161
// initialValue: Colors.yellow,
6262
colorPickerType: ColorPickerType.MaterialPicker,
6363
decoration: InputDecoration(labelText: 'Pick Color'),
6464
),
6565
FormBuilderChipsInput(
6666
decoration: InputDecoration(labelText: 'Chips'),
67-
attribute: 'chips_test',
67+
name: 'chips_test',
6868
onChanged: _onChanged,
6969
initialValue: [
7070
Contact('Andrew', '[email protected]',
@@ -116,7 +116,7 @@ Column(
116116
},
117117
),
118118
FormBuilderDateTimePicker(
119-
attribute: 'date',
119+
name: 'date',
120120
// onChanged: _onChanged,
121121
inputType: InputType.time,
122122
decoration: InputDecoration(
@@ -127,7 +127,7 @@ Column(
127127
// readonly: true,
128128
),
129129
FormBuilderDateRangePicker(
130-
attribute: 'date_range',
130+
name: 'date_range',
131131
firstDate: DateTime(1970),
132132
lastDate: DateTime(2030),
133133
format: DateFormat('yyyy-MM-dd'),
@@ -139,7 +139,7 @@ Column(
139139
),
140140
),
141141
FormBuilderSlider(
142-
attribute: 'slider',
142+
name: 'slider',
143143
validator: FormBuilderValidators.compose([
144144
FormBuilderValidators.min(context, 6),
145145
]),
@@ -155,7 +155,7 @@ Column(
155155
),
156156
),
157157
FormBuilderCheckbox(
158-
attribute: 'accept_terms',
158+
name: 'accept_terms',
159159
initialValue: false,
160160
onChanged: _onChanged,
161161
title: RichText(
@@ -185,7 +185,7 @@ Column(
185185
]),
186186
),
187187
FormBuilderTextField(
188-
attribute: 'age',
188+
name: 'age',
189189
decoration: InputDecoration(
190190
labelText:
191191
'This value is passed along to the [Text.maxLines] attribute of the [Text] widget used to display the hint text.',
@@ -200,7 +200,7 @@ Column(
200200
keyboardType: TextInputType.number,
201201
),
202202
FormBuilderDropdown(
203-
attribute: 'gender',
203+
name: 'gender',
204204
decoration: InputDecoration(
205205
labelText: 'Gender',
206206
),
@@ -220,7 +220,7 @@ Column(
220220
decoration: InputDecoration(
221221
labelText: 'Country',
222222
),
223-
attribute: 'country',
223+
name: 'country',
224224
onChanged: _onChanged,
225225
itemBuilder: (context, country) {
226226
return ListTile(
@@ -248,7 +248,7 @@ Column(
248248
FormBuilderRadioList(
249249
decoration:
250250
InputDecoration(labelText: 'My chosen language'),
251-
attribute: 'best_language',
251+
name: 'best_language',
252252
onChanged: _onChanged,
253253
validator: FormBuilderValidators.compose(
254254
[FormBuilderValidators.required(context)]),
@@ -261,7 +261,7 @@ Column(
261261
),
262262
FormBuilderTouchSpin(
263263
decoration: InputDecoration(labelText: 'Stepper'),
264-
attribute: 'stepper',
264+
name: 'stepper',
265265
initialValue: 10,
266266
step: 1,
267267
iconSize: 48.0,
@@ -270,7 +270,7 @@ Column(
270270
),
271271
FormBuilderRating(
272272
decoration: InputDecoration(labelText: 'Rate this form'),
273-
attribute: 'rate',
273+
name: 'rate',
274274
iconSize: 32.0,
275275
initialValue: 1.0,
276276
max: 5.0,
@@ -386,7 +386,7 @@ var options = ["Option 1", "Option 2", "Option 3"];
386386

387387
```dart
388388
FormBuilderField(
389-
attribute: "name",
389+
name: "name",
390390
validator: FormBuilderValidators.compose([
391391
FormBuilderValidators.required(context),
392392
]),
@@ -414,6 +414,25 @@ FormBuilderField(
414414
),
415415
```
416416

417+
### Programmatically changing field value
418+
You can either change the value of one field at a time like so:
419+
```dart
420+
_fbKey.currentState.fields['color_picker'].patchValue(Colors.black);
421+
```
422+
Or multiple field value like so:
423+
```dart
424+
_fbKey.currentState.patchValue({
425+
'age': '50',
426+
'slider': 6.7,
427+
'filter_chip': ['Test 1'],
428+
'choice_chip': 'Test 2',
429+
'rate': 4,
430+
'chips_test': [
431+
Contact('Andrew', '[email protected]', 'https://d2gg9evh47fn9z.cloudfront.net/800px_COLOURBOX4057996.jpg'),
432+
],
433+
});
434+
```
435+
417436
## Validation
418437
The `validator` attribute in fields take in a `FormFieldValidator` which checks the validity of the field. A `FormFieldValidator` returns `null` if validation is successful and a `String` for the `errorText` if validation fails.
419438

@@ -443,7 +462,7 @@ Available built-in validators include:
443462
Validation example:
444463
```dart
445464
FormBuilderTextField(
446-
attribute: "age",
465+
name: "age",
447466
decoration: InputDecoration(labelText: "Age"),
448467
validator: FormBuilderValidators.compose([
449468
FormBuilderValidators.numeric(context, errorText: "La edad debe ser numérica."),
@@ -466,7 +485,7 @@ String _emailError;
466485
Use the variable as the `errorText` within `InputDecoration`
467486
```dart
468487
FormBuilderTextField(
469-
attribute: 'email',
488+
name: 'email',
470489
decoration: InputDecoration(
471490
labelText: 'Email',
472491
errorText: _emailError,
@@ -496,7 +515,7 @@ You can also validate a field based on the value of another field
496515
```
497516
FormBuilderRadioGroup(
498517
decoration: InputDecoration(labelText: 'My best language'),
499-
attribute: 'my_language',
518+
name: 'my_language',
500519
validator: FormBuilderValidators.required(context),
501520
options: [
502521
'Dart',
@@ -510,7 +529,7 @@ FormBuilderRadioGroup(
510529
.toList(growable: false),
511530
),
512531
FormBuilderTextField(
513-
attribute: 'specify',
532+
name: 'specify',
514533
decoration:
515534
InputDecoration(labelText: 'If Other, please specify'),
516535
validator: (val) {

example/README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ FormBuilder(
1212
child: Column(
1313
children: <Widget>[
1414
FormBuilderFilterChip(
15-
attribute: 'filter_chip',
15+
name: 'filter_chip',
1616
decoration: InputDecoration(
1717
labelText: 'Select many options',
1818
),
@@ -30,7 +30,7 @@ FormBuilder(
3030
],
3131
),
3232
FormBuilderChoiceChip(
33-
attribute: 'choice_chip',
33+
name: 'choice_chip',
3434
decoration: InputDecoration(
3535
labelText: 'Select an option',
3636
),
@@ -48,14 +48,14 @@ FormBuilder(
4848
],
4949
),
5050
FormBuilderColorPickerField(
51-
attribute: 'color_picker',
51+
name: 'color_picker',
5252
// initialValue: Colors.yellow,
5353
colorPickerType: ColorPickerType.MaterialPicker,
5454
decoration: InputDecoration(labelText: 'Pick Color'),
5555
),
5656
FormBuilderChipsInput(
5757
decoration: InputDecoration(labelText: 'Chips'),
58-
attribute: 'chips_test',
58+
name: 'chips_test',
5959
onChanged: _onChanged,
6060
initialValue: [
6161
Contact('Andrew', '[email protected]',
@@ -107,7 +107,7 @@ FormBuilder(
107107
},
108108
),
109109
FormBuilderDateTimePicker(
110-
attribute: 'date',
110+
name: 'date',
111111
// onChanged: _onChanged,
112112
inputType: InputType.time,
113113
decoration: InputDecoration(
@@ -118,7 +118,7 @@ FormBuilder(
118118
// readonly: true,
119119
),
120120
FormBuilderDateRangePicker(
121-
attribute: 'date_range',
121+
name: 'date_range',
122122
firstDate: DateTime(1970),
123123
lastDate: DateTime(2030),
124124
format: DateFormat('yyyy-MM-dd'),
@@ -130,7 +130,7 @@ FormBuilder(
130130
),
131131
),
132132
FormBuilderSlider(
133-
attribute: 'slider',
133+
name: 'slider',
134134
validator: FormBuilderValidators.compose([
135135
FormBuilderValidators.min(context, 6),
136136
]),
@@ -146,7 +146,7 @@ FormBuilder(
146146
),
147147
),
148148
FormBuilderCheckbox(
149-
attribute: 'accept_terms',
149+
name: 'accept_terms',
150150
initialValue: false,
151151
onChanged: _onChanged,
152152
title: RichText(
@@ -176,7 +176,7 @@ FormBuilder(
176176
]),
177177
),
178178
FormBuilderTextField(
179-
attribute: 'age',
179+
name: 'age',
180180
decoration: InputDecoration(
181181
labelText:
182182
'This value is passed along to the [Text.maxLines] attribute of the [Text] widget used to display the hint text.',
@@ -191,7 +191,7 @@ FormBuilder(
191191
keyboardType: TextInputType.number,
192192
),
193193
FormBuilderDropdown(
194-
attribute: 'gender',
194+
name: 'gender',
195195
decoration: InputDecoration(
196196
labelText: 'Gender',
197197
),
@@ -211,7 +211,7 @@ FormBuilder(
211211
decoration: InputDecoration(
212212
labelText: 'Country',
213213
),
214-
attribute: 'country',
214+
name: 'country',
215215
onChanged: _onChanged,
216216
itemBuilder: (context, country) {
217217
return ListTile(
@@ -239,7 +239,7 @@ FormBuilder(
239239
FormBuilderRadioList(
240240
decoration:
241241
InputDecoration(labelText: 'My chosen language'),
242-
attribute: 'best_language',
242+
name: 'best_language',
243243
onChanged: _onChanged,
244244
validator: FormBuilderValidators.compose(
245245
[FormBuilderValidators.required(context)]),
@@ -252,7 +252,7 @@ FormBuilder(
252252
),
253253
FormBuilderTouchSpin(
254254
decoration: InputDecoration(labelText: 'Stepper'),
255-
attribute: 'stepper',
255+
name: 'stepper',
256256
initialValue: 10,
257257
step: 1,
258258
iconSize: 48.0,
@@ -261,7 +261,7 @@ FormBuilder(
261261
),
262262
FormBuilderRating(
263263
decoration: InputDecoration(labelText: 'Rate this form'),
264-
attribute: 'rate',
264+
name: 'rate',
265265
iconSize: 32.0,
266266
initialValue: 1.0,
267267
max: 5.0,

lib/src/fields/form_builder_image_picker.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class FormBuilderImagePicker extends FormBuilderField {
3636
final Widget galleryLabel;
3737
final EdgeInsets bottomSheetPadding;
3838

39-
FormBuilderImagePicker( {
39+
FormBuilderImagePicker({
4040
Key key,
4141
//From Super
4242
@required String name,

lib/src/fields/form_builder_searchable_dropdown.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ class FormBuilderSearchableDropdown<T> extends FormBuilderField {
101101
enabled: state.readOnly,
102102
errorText: decoration?.errorText ?? field.errorText,
103103
),
104-
child: /*SearchableDropdown.single(
104+
child:
105+
/*SearchableDropdown.single(
105106
value: state.value,
106107
items: items,
107108
onChanged: (val) {
@@ -136,7 +137,7 @@ class FormBuilderSearchableDropdown<T> extends FormBuilderField {
136137
menuBackgroundColor: menuBackgroundColor,
137138
assertUniqueValue: assertUniqueValue,
138139
)*/
139-
SearchableDropdown.multiple(
140+
SearchableDropdown.multiple(
140141
items: items,
141142
onChanged: (val) {
142143
state.requestFocus();
@@ -168,9 +169,8 @@ class FormBuilderSearchableDropdown<T> extends FormBuilderField {
168169
menuConstraints: menuConstraints,
169170
readOnly: readOnly,
170171
menuBackgroundColor: menuBackgroundColor,
171-
selectedItems: ,
172-
)
173-
,
172+
// selectedItems: ,
173+
),
174174
);
175175
},
176176
);

lib/src/fields/form_builder_text_field.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class _FormBuilderTextFieldState extends FormBuilderFieldState {
232232
}
233233

234234
@override
235-
void patchValue(dynamic val){
235+
void patchValue(dynamic val) {
236236
_effectiveController.text = val;
237237
}
238238
}

lib/src/form_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class FormBuilderState extends State<FormBuilder> {
185185
_formKey.currentState.reset();
186186
}
187187

188-
void patchValue(Map<String, dynamic> val){
188+
void patchValue(Map<String, dynamic> val) {
189189
val.forEach((key, value) {
190190
_fields[key]?.patchValue(value);
191191
});

0 commit comments

Comments
 (0)