Skip to content

Commit e19f1f7

Browse files
committed
A bit of code cleanup and refactoring
1 parent fd5565c commit e19f1f7

File tree

3 files changed

+48
-48
lines changed

3 files changed

+48
-48
lines changed

lib/src/fields/form_builder_chips_input.dart

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -55,52 +55,53 @@ class FormBuilderChipsInput<T> extends FormBuilderField<List<T>> {
5555
this.autofocus = false,
5656
this.textOverflow,
5757
}) : super(
58-
key: key,
59-
initialValue: initialValue,
60-
name: name,
61-
validator: validator,
62-
valueTransformer: valueTransformer,
63-
onChanged: onChanged,
64-
readOnly: readOnly,
65-
autovalidateMode: autovalidateMode,
66-
onSaved: onSaved,
67-
enabled: enabled,
68-
onReset: onReset,
69-
decoration: decoration,
70-
focusNode: focusNode,
71-
builder: (FormFieldState field) {
72-
final _FormBuilderChipsInputState state = field;
58+
key: key,
59+
initialValue: initialValue,
60+
name: name,
61+
validator: validator,
62+
valueTransformer: valueTransformer,
63+
onChanged: onChanged,
64+
readOnly: readOnly,
65+
autovalidateMode: autovalidateMode,
66+
onSaved: onSaved,
67+
enabled: enabled,
68+
onReset: onReset,
69+
decoration: decoration,
70+
focusNode: focusNode,
71+
builder: (FormFieldState field) {
72+
final _FormBuilderChipsInputState state = field;
7373

74-
return ChipsInput(
75-
key: ObjectKey(state.value),
76-
initialValue: field.value,
74+
return ChipsInput(
75+
key: ObjectKey(state.value),
76+
initialValue: field.value,
77+
enabled: !state.readOnly,
78+
decoration: decoration.copyWith(
7779
enabled: !state.readOnly,
78-
decoration: decoration.copyWith(
79-
enabled: !state.readOnly,
80-
errorText: decoration?.errorText ?? field.errorText,
81-
),
82-
findSuggestions: findSuggestions,
83-
onChanged: (data) {
84-
field.didChange(data);
85-
},
86-
maxChips: maxChips,
87-
chipBuilder: chipBuilder,
88-
suggestionBuilder: suggestionBuilder,
89-
textStyle: textStyle,
90-
actionLabel: actionLabel,
91-
autocorrect: autocorrect,
92-
inputAction: inputAction,
93-
inputType: inputType,
94-
keyboardAppearance: keyboardAppearance,
95-
obscureText: obscureText,
96-
suggestionsBoxMaxHeight: suggestionsBoxMaxHeight,
97-
textCapitalization: textCapitalization,
98-
allowChipEditing: allowChipEditing,
99-
autofocus: autofocus,
100-
focusNode: state.effectiveFocusNode,
101-
textOverflow: textOverflow,
102-
);
103-
},);
80+
errorText: decoration?.errorText ?? field.errorText,
81+
),
82+
findSuggestions: findSuggestions,
83+
onChanged: (data) {
84+
field.didChange(data);
85+
},
86+
maxChips: maxChips,
87+
chipBuilder: chipBuilder,
88+
suggestionBuilder: suggestionBuilder,
89+
textStyle: textStyle,
90+
actionLabel: actionLabel,
91+
autocorrect: autocorrect,
92+
inputAction: inputAction,
93+
inputType: inputType,
94+
keyboardAppearance: keyboardAppearance,
95+
obscureText: obscureText,
96+
suggestionsBoxMaxHeight: suggestionsBoxMaxHeight,
97+
textCapitalization: textCapitalization,
98+
allowChipEditing: allowChipEditing,
99+
autofocus: autofocus,
100+
focusNode: state.effectiveFocusNode,
101+
textOverflow: textOverflow,
102+
);
103+
},
104+
);
104105

105106
@override
106107
_FormBuilderChipsInputState<T> createState() => _FormBuilderChipsInputState();

lib/src/utils.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ String enumValueToString(Object o) {
44

55
T enumValueFromString<T>(String key, Iterable<T> values) {
66
return values.firstWhere(
7-
(v) => v != null && key == enumValueToString(v),
8-
orElse: () => null,
9-
);
7+
(v) => v != null && key == enumValueToString(v),
8+
orElse: () => null,
9+
);
1010
}

lib/src/widgets/grouped_checkbox.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ class _GroupedCheckboxState<T> extends State<GroupedCheckbox<T>> {
218218
}
219219

220220
Widget generateItems() {
221-
var content = <Widget>[];
222221
Widget finalWidget;
223222
if (widget.value != null) {
224223
selectedListItems = widget.value;

0 commit comments

Comments
 (0)