Skip to content

Commit 013729c

Browse files
authored
Merge pull request #528 from awhitford/code-tweaks
Minor code tweaks
2 parents d098829 + bd0ccf3 commit 013729c

File tree

5 files changed

+8
-12
lines changed

5 files changed

+8
-12
lines changed

example/lib/sources/complete_form.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CompleteFormState extends State<CompleteForm> {
1818
bool autoValidate = true;
1919
bool readOnly = false;
2020
bool showSegmentedControl = true;
21-
final GlobalKey<FormBuilderState> _formKey = GlobalKey<FormBuilderState>();
21+
final _formKey = GlobalKey<FormBuilderState>();
2222
bool _ageHasError = false;
2323
bool _genderHasError = false;
2424

example/lib/sources/signup_form.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class SignupForm extends StatefulWidget {
77
}
88

99
class _SignupFormState extends State<SignupForm> {
10-
final GlobalKey<FormBuilderState> _formKey = GlobalKey();
10+
final _formKey = GlobalKey<FormBuilderState>();
1111

1212
@override
1313
Widget build(BuildContext context) {

lib/src/fields/form_builder_dropdown.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,7 @@ class FormBuilderDropdown<T> extends FormBuilderField<T> {
266266
iconEnabledColor: iconEnabledColor,
267267
onChanged: (state.readOnly || !enabled)
268268
? null
269-
: (T value) {
270-
_changeValue<T>(field, value);
271-
},
269+
: (T value) => _changeValue<T>(field, value),
272270
onTap: onTap,
273271
focusNode: state.effectiveFocusNode,
274272
autofocus: autofocus,
@@ -280,12 +278,10 @@ class FormBuilderDropdown<T> extends FormBuilderField<T> {
280278
),
281279
),
282280
if (allowClear && !readOnly && field.value != null) ...[
283-
VerticalDivider(),
281+
const VerticalDivider(),
284282
InkWell(
285283
child: clearIcon,
286-
onTap: () {
287-
_changeValue(state, null);
288-
},
284+
onTap: () => _changeValue<T>(state, null),
289285
),
290286
]
291287
],

lib/src/fields/form_builder_image_picker.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class FormBuilderImagePicker extends FormBuilderField<List<dynamic>> {
101101
scrollDirection: Axis.horizontal,
102102
children: [
103103
if (field.value != null)
104-
...(field.value.map<Widget>((item) {
104+
...field.value.map<Widget>((item) {
105105
return Stack(
106106
alignment: Alignment.topRight,
107107
children: <Widget>[
@@ -140,7 +140,7 @@ class FormBuilderImagePicker extends FormBuilderField<List<dynamic>> {
140140
),
141141
],
142142
);
143-
}).toList()),
143+
}),
144144
if (!state.readOnly && !state.hasMaxImages)
145145
GestureDetector(
146146
child: placeholderImage != null

lib/src/form_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class FormBuilder extends StatefulWidget {
7474

7575
class FormBuilderState extends State<FormBuilder> {
7676
//TODO: Find way to assert no duplicates in field names
77-
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
77+
final _formKey = GlobalKey<FormState>();
7878

7979
Map<String, FormBuilderFieldState> _fields;
8080

0 commit comments

Comments
 (0)