Skip to content

Commit bc4fa8c

Browse files
authored
Merge pull request #576 from awhitford/FocusNode
Fix: FocusNode parameters
2 parents 43923e9 + 0c6ffdf commit bc4fa8c

12 files changed

+24
-9
lines changed

lib/src/fields/form_builder_color_picker.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ class FormBuilderColorPickerField extends FormBuilderField<Color> {
101101
this.maxLength,
102102
this.onEditingComplete,
103103
this.onFieldSubmitted,
104-
// FormFieldValidator<String> validator,
105104
this.inputFormatters,
106105
this.cursorWidth = 2.0,
107106
this.cursorRadius,
@@ -122,6 +121,7 @@ class FormBuilderColorPickerField extends FormBuilderField<Color> {
122121
enabled: enabled,
123122
onReset: onReset,
124123
decoration: decoration,
124+
focusNode: focusNode,
125125
builder: (FormFieldState<Color> field) {
126126
final state = field as _FormBuilderColorPickerFieldState;
127127
return TextField(
@@ -201,6 +201,7 @@ class _FormBuilderColorPickerFieldState
201201

202202
@override
203203
void dispose() {
204+
effectiveFocusNode.removeListener(_handleFocus);
204205
// Dispose the _effectiveController when initState created it
205206
if (null == widget.controller) {
206207
_effectiveController.dispose();

lib/src/fields/form_builder_date_range_picker.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class FormBuilderDateRangePickerState
198198

199199
@override
200200
void dispose() {
201+
effectiveFocusNode.removeListener(_handleFocus);
201202
// Dispose the _effectiveController when initState created it
202203
if (null == widget.controller) {
203204
_effectiveController.dispose();

lib/src/fields/form_builder_dropdown.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ class FormBuilderDropdown<T> extends FormBuilderField<T> {
224224
enabled: enabled,
225225
onReset: onReset,
226226
decoration: decoration,
227+
focusNode: focusNode,
227228
builder: (FormFieldState<T> field) {
228229
final state = field as _FormBuilderDropdownState<T>;
229230
// DropdownButtonFormField
@@ -265,8 +266,9 @@ class FormBuilderDropdown<T> extends FormBuilderField<T> {
265266
icon: icon,
266267
iconDisabledColor: iconDisabledColor,
267268
iconEnabledColor: iconEnabledColor,
268-
onChanged:
269-
state.enabled ? (value) => changeValue(value) : null,
269+
onChanged: state.enabled
270+
? (value) => changeValue(value)
271+
: null,
270272
onTap: onTap,
271273
focusNode: state.effectiveFocusNode,
272274
autofocus: autofocus,

lib/src/fields/form_builder_phone_field.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class FormBuilderPhoneField extends FormBuilderField<String> {
120120
enabled: enabled,
121121
onReset: onReset,
122122
decoration: decoration,
123+
focusNode: focusNode,
123124
builder: (FormFieldState<String> field) {
124125
final state = field as _FormBuilderPhoneFieldState;
125126

lib/src/fields/form_builder_range_slider.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class FormBuilderRangeSlider extends FormBuilderField<RangeValues> {
143143
enabled: enabled,
144144
onReset: onReset,
145145
decoration: decoration,
146+
focusNode: focusNode,
146147
builder: (FormFieldState<RangeValues> field) {
147148
final state = field as _FormBuilderRangeSliderState;
148149
final _numberFormat = numberFormat ?? NumberFormat.compact();

lib/src/fields/form_builder_rating.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class FormBuilderRating extends FormBuilderField<double> {
6767
enabled: enabled,
6868
onReset: onReset,
6969
decoration: decoration,
70+
focusNode: focusNode,
7071
builder: (FormFieldState<double> field) {
7172
final state = field as _FormBuilderRateState;
7273
final widget = state.widget;

lib/src/fields/form_builder_searchable_dropdown.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ class FormBuilderSearchableDropdown<T> extends FormBuilderField<T> {
156156
enabled: enabled,
157157
onReset: onReset,
158158
decoration: decoration,
159+
focusNode: focusNode,
159160
builder: (FormFieldState<T> field) {
160161
final state = field as _FormBuilderSearchableDropdownState<T>;
161162

lib/src/fields/form_builder_segmented_control.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class FormBuilderSegmentedControl<T> extends FormBuilderField<T> {
6767
enabled: enabled,
6868
onReset: onReset,
6969
decoration: decoration,
70+
focusNode: focusNode,
7071
builder: (FormFieldState<T> field) {
7172
final state = field as _FormBuilderSegmentedControlState<T>;
7273
final theme = Theme.of(state.context);

lib/src/fields/form_builder_signature_pad.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ class FormBuilderSignaturePad extends FormBuilderField<Uint8List> {
5858
enabled: enabled,
5959
onReset: onReset,
6060
decoration: decoration,
61+
focusNode: focusNode,
6162
builder: (FormFieldState<Uint8List> field) {
6263
final state = field as _FormBuilderSignaturePadState;
6364
final theme = Theme.of(state.context);
6465
final localizations = MaterialLocalizations.of(state.context);
65-
final cancelButtonColor = state.enabled ? theme.errorColor : theme.disabledColor;
66+
final cancelButtonColor =
67+
state.enabled ? theme.errorColor : theme.disabledColor;
6668

6769
return InputDecorator(
6870
decoration: state.decoration(),
@@ -85,10 +87,12 @@ class FormBuilderSignaturePad extends FormBuilderField<Uint8List> {
8587
children: <Widget>[
8688
Expanded(child: const SizedBox()),
8789
TextButton.icon(
88-
onPressed: state.enabled ? () {
89-
state._controller.clear();
90-
field.didChange(null);
91-
} : null,
90+
onPressed: state.enabled
91+
? () {
92+
state._controller.clear();
93+
field.didChange(null);
94+
}
95+
: null,
9296
label: Text(
9397
clearButtonText ?? localizations.cancelButtonLabel,
9498
style: TextStyle(color: cancelButtonColor),

lib/src/fields/form_builder_slider.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class FormBuilderSlider extends FormBuilderField<double> {
169169
enabled: enabled,
170170
onReset: onReset,
171171
decoration: decoration,
172+
focusNode: focusNode,
172173
builder: (FormFieldState<double> field) {
173174
final state = field as _FormBuilderSliderState;
174175
final _numberFormat = numberFormat ?? NumberFormat.compact();

0 commit comments

Comments
 (0)