Skip to content

Commit 1c1d6fa

Browse files
committed
Rename updateFormAttributeValue to setInternalAttributeValue to avoid confusion
1 parent 1d042a4 commit 1c1d6fa

File tree

6 files changed

+42
-32
lines changed

6 files changed

+42
-32
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [4.0.0-alpha.6] - 20-Jul-2020
2+
* Added focusNode to all fields.
3+
* Attempted tab/next support - work in progress
4+
* Request Focus to Field when change is attempted.
5+
* Include guide to programmatically inducing errors to README. Closes #123
6+
* Fixed bug in Localization where `Locale.countrycCode` is `null`. Closes #369
7+
* Added more options to DatePicker for showDatePicker() Flutter function
8+
* Rename `updateFormAttributeValue` to `setInternalAttributeValue` to avoid confusion
9+
110
## [4.0.0-alpha.5] - 08-Jul-2020
211
* Improvements to dirty check for FormBuilderField - fixes autovalidate only when dirty
312

lib/src/fields/form_builder_date_time_picker.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class FormBuilderDateTimePicker extends FormBuilderField {
169169
this.initialDate,
170170
// this.onSaved,
171171
this.onFieldSubmitted,
172-
this.initialDatePickerMode,
172+
this.initialDatePickerMode = DatePickerMode.day,
173173
this.locale,
174174
this.selectableDayPredicate,
175175
this.textDirection,
@@ -199,7 +199,7 @@ class FormBuilderDateTimePicker extends FormBuilderField {
199199
this.fieldHintText,
200200
this.fieldLabelText,
201201
this.helpText,
202-
this.initialEntryMode,
202+
this.initialEntryMode = DatePickerEntryMode.calendar,
203203
this.routeSettings,
204204
}) : super(
205205
key: key,

lib/src/fields/form_builder_dropdown.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class FormBuilderDropdown<T> extends FormBuilderField<T> {
1111
final int elevation;
1212
final Widget disabledHint;
1313
final double iconSize;
14-
final Widget underline;
1514
final Widget icon;
1615
final Color iconDisabledColor;
1716
final Color iconEnabledColor;
@@ -47,7 +46,6 @@ class FormBuilderDropdown<T> extends FormBuilderField<T> {
4746
this.hint,
4847
this.style,
4948
this.disabledHint,
50-
this.underline,
5149
this.icon,
5250
this.iconDisabledColor,
5351
this.iconEnabledColor,
@@ -79,11 +77,14 @@ class FormBuilderDropdown<T> extends FormBuilderField<T> {
7977
decoration: decoration.copyWith(
8078
enabled: !state.readOnly,
8179
errorText: field.errorText,
80+
floatingLabelBehavior: hint == null
81+
? decoration.floatingLabelBehavior
82+
: FloatingLabelBehavior.always,
8283
),
83-
child: DropdownButtonHideUnderline(
84-
child: Row(
85-
children: <Widget>[
86-
Expanded(
84+
child: Row(
85+
children: <Widget>[
86+
Expanded(
87+
child: DropdownButtonHideUnderline(
8788
child: DropdownButton(
8889
isExpanded: isExpanded,
8990
hint: hint,
@@ -104,7 +105,6 @@ class FormBuilderDropdown<T> extends FormBuilderField<T> {
104105
icon: icon,
105106
iconDisabledColor: iconDisabledColor,
106107
iconEnabledColor: iconEnabledColor,
107-
underline: underline,
108108
onChanged: state.readOnly
109109
? null
110110
: (value) {
@@ -119,17 +119,17 @@ class FormBuilderDropdown<T> extends FormBuilderField<T> {
119119
selectedItemBuilder: selectedItemBuilder,
120120
),
121121
),
122-
if (allowClear && !readOnly && field.value != null) ...[
123-
VerticalDivider(),
124-
InkWell(
125-
child: clearIcon,
126-
onTap: () {
127-
_changeValue(state, null);
128-
},
129-
),
130-
]
131-
],
132-
),
122+
),
123+
if (allowClear && !readOnly && field.value != null) ...[
124+
VerticalDivider(),
125+
InkWell(
126+
child: clearIcon,
127+
onTap: () {
128+
_changeValue(state, null);
129+
},
130+
),
131+
]
132+
],
133133
),
134134
);
135135
});

lib/src/form_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class FormBuilderState extends State<FormBuilder> {
120120
super.dispose();
121121
}
122122

123-
void updateFormAttributeValue(String attribute, dynamic value) {
123+
void setInternalAttributeValue(String attribute, dynamic value) {
124124
setState(() {
125125
_value = {..._value, attribute: value};
126126
});

lib/src/form_builder_field.dart

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ class FormBuilderFieldState<T> extends FormFieldState<T> {
7373

7474
FocusNode _node;
7575

76-
FocusAttachment _nodeAttachment;
77-
7876
bool _focused = false;
7977

8078
@override
@@ -90,7 +88,7 @@ class FormBuilderFieldState<T> extends FormFieldState<T> {
9088
: null);
9189
_node = widget.focusNode ?? FocusNode(debugLabel: '${widget.attribute}');
9290
_node.addListener(_handleFocusChange);
93-
_nodeAttachment = _node.attach(context, onKey: _handleKeyPress);
91+
_node.attach(context, onKey: _handleKeyPress);
9492
setValue(_initialValue);
9593
}
9694

@@ -113,16 +111,10 @@ class FormBuilderFieldState<T> extends FormFieldState<T> {
113111
return false;
114112
}
115113

116-
@override
117-
void dispose() {
118-
_formBuilderState?.unregisterFieldKey(widget.attribute);
119-
super.dispose();
120-
}
121-
122114
@override
123115
void save() {
124116
super.save();
125-
_formBuilderState?.updateFormAttributeValue(
117+
_formBuilderState?.setInternalAttributeValue(
126118
widget.attribute, widget.valueTransformer?.call(value) ?? value);
127119
}
128120

@@ -150,4 +142,13 @@ class FormBuilderFieldState<T> extends FormFieldState<T> {
150142
void requestFocus() {
151143
FocusScope.of(context).requestFocus(_node);
152144
}
145+
146+
@override
147+
void dispose() {
148+
_formBuilderState?.unregisterFieldKey(widget.attribute);
149+
_node.removeListener(_handleFocusChange);
150+
// The attachment will automatically be detached in dispose().
151+
_node.dispose();
152+
super.dispose();
153+
}
153154
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_form_builder
22
description: Package to build Material Form with fields like TextField, DropDown, Switches etc. with ability to create custom FormFields and composability and reuse validation functions.
3-
version: 4.0.0-alpha.5
3+
version: 4.0.0-alpha.6
44
homepage: https://github.com/danvick/flutter_form_builder
55

66
environment:

0 commit comments

Comments
 (0)