Skip to content

Commit b136446

Browse files
style: apply new dart format
1 parent ebd4f90 commit b136446

11 files changed

+126
-120
lines changed

example/lib/main.dart

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ class MyHomePageState extends State<MyHomePage> {
8585
decoration: const InputDecoration(
8686
labelText: 'Searchable Dropdown Offline',
8787
),
88-
filterFn:
89-
(country, filter) =>
90-
country.toLowerCase().contains(filter.toLowerCase()),
88+
filterFn: (country, filter) =>
89+
country.toLowerCase().contains(filter.toLowerCase()),
9190
),
9291
const SizedBox(height: 15),
9392
FormBuilderColorPickerField(
@@ -112,15 +111,20 @@ class MyHomePageState extends State<MyHomePage> {
112111
if (query.isNotEmpty) {
113112
var lowercaseQuery = query.toLowerCase();
114113
return allCountries
115-
.where((country) {
116-
return country.toLowerCase().contains(lowercaseQuery);
117-
})
118-
.toList(growable: false)..sort(
119-
(a, b) => a
120-
.toLowerCase()
121-
.indexOf(lowercaseQuery)
122-
.compareTo(b.toLowerCase().indexOf(lowercaseQuery)),
123-
);
114+
.where((country) {
115+
return country.toLowerCase().contains(
116+
lowercaseQuery,
117+
);
118+
})
119+
.toList(growable: false)
120+
..sort(
121+
(a, b) => a
122+
.toLowerCase()
123+
.indexOf(lowercaseQuery)
124+
.compareTo(
125+
b.toLowerCase().indexOf(lowercaseQuery),
126+
),
127+
);
124128
} else {
125129
return allCountries;
126130
}

lib/src/fields/form_builder_color_picker.dart

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,19 @@ class FormBuilderColorPickerField extends FormBuilderFieldDecoration<Color> {
9797
return TextField(
9898
style: style,
9999
decoration: state.decoration.copyWith(
100-
suffixIcon:
101-
colorPreviewBuilder != null
102-
? colorPreviewBuilder(field.value)
103-
: LayoutBuilder(
104-
key: ObjectKey(state.value),
105-
builder: (context, constraints) {
106-
return Icon(
107-
Icons.circle,
108-
key: ObjectKey(state.value),
109-
size: constraints.minHeight,
110-
color: state.value,
111-
);
112-
},
113-
),
100+
suffixIcon: colorPreviewBuilder != null
101+
? colorPreviewBuilder(field.value)
102+
: LayoutBuilder(
103+
key: ObjectKey(state.value),
104+
builder: (context, constraints) {
105+
return Icon(
106+
Icons.circle,
107+
key: ObjectKey(state.value),
108+
size: constraints.minHeight,
109+
color: state.value,
110+
);
111+
},
112+
),
114113
),
115114
enabled: state.enabled,
116115
readOnly: readOnly,

lib/src/fields/form_builder_searchable_dropdown.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,9 @@ class FormBuilderSearchableDropdown<T> extends FormBuilderFieldDecoration<T> {
152152
baseStyle: dropdownSearchTextStyle,
153153
),
154154
filterFn: filterFn,
155-
items:
156-
(filter, infiniteScrollProps) =>
157-
asyncItems == null
158-
? items
159-
: asyncItems(filter, infiniteScrollProps),
155+
items: (filter, infiniteScrollProps) => asyncItems == null
156+
? items
157+
: asyncItems(filter, infiniteScrollProps),
160158
itemAsString: itemAsString,
161159
onBeforeChange: onBeforeChange,
162160
onChanged: (value) {

lib/src/fields/form_builder_signature_pad.dart

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ class FormBuilderSignaturePad extends FormBuilderFieldDecoration<Uint8List> {
6060
final state = field as FormBuilderSignaturePadState;
6161
final theme = Theme.of(state.context);
6262
final localizations = MaterialLocalizations.of(state.context);
63-
final cancelButtonColor =
64-
state.enabled ? theme.colorScheme.error : theme.disabledColor;
63+
final cancelButtonColor = state.enabled
64+
? theme.colorScheme.error
65+
: theme.disabledColor;
6566

6667
return InputDecorator(
6768
decoration: state.decoration,
@@ -72,36 +73,33 @@ class FormBuilderSignaturePad extends FormBuilderFieldDecoration<Uint8List> {
7273
width: width,
7374
decoration: BoxDecoration(
7475
border: border,
75-
image:
76-
null != initialValue && initialValue == state.value
77-
? DecorationImage(image: MemoryImage(state.value!))
78-
: null,
76+
image: null != initialValue && initialValue == state.value
77+
? DecorationImage(image: MemoryImage(state.value!))
78+
: null,
7979
),
80-
child:
81-
state.enabled
82-
? GestureDetector(
83-
onHorizontalDragUpdate: (_) {},
84-
onVerticalDragUpdate: (_) {},
85-
child: Signature(
86-
controller: state.effectiveController,
87-
width: width,
88-
height: height,
89-
backgroundColor: backgroundColor,
90-
),
91-
)
92-
: null,
80+
child: state.enabled
81+
? GestureDetector(
82+
onHorizontalDragUpdate: (_) {},
83+
onVerticalDragUpdate: (_) {},
84+
child: Signature(
85+
controller: state.effectiveController,
86+
width: width,
87+
height: height,
88+
backgroundColor: backgroundColor,
89+
),
90+
)
91+
: null,
9392
),
9493
Row(
9594
children: <Widget>[
9695
const Expanded(child: SizedBox()),
9796
TextButton.icon(
98-
onPressed:
99-
state.enabled
100-
? () {
101-
state.effectiveController.clear();
102-
field.didChange(null);
103-
}
104-
: null,
97+
onPressed: state.enabled
98+
? () {
99+
state.effectiveController.clear();
100+
field.didChange(null);
101+
}
102+
: null,
105103
label: Text(
106104
clearButtonText ?? localizations.cancelButtonLabel,
107105
style: TextStyle(color: cancelButtonColor),

lib/src/fields/form_builder_touch_spin.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,11 @@ class FormBuilderTouchSpin extends FormBuilderFieldDecoration<num> {
8282
step: step,
8383
value: field.value ?? 0,
8484
iconSize: iconSize,
85-
onChanged:
86-
state.enabled
87-
? (value) {
88-
state.didChange(value);
89-
}
90-
: null,
85+
onChanged: state.enabled
86+
? (value) {
87+
state.didChange(value);
88+
}
89+
: null,
9190
displayFormat: displayFormat,
9291
textStyle: textStyle,
9392
addIcon: addIcon,

lib/src/fields/form_builder_typeahead.dart

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -113,29 +113,27 @@ class FormBuilderTypeAhead<T> extends FormBuilderFieldDecoration<T> {
113113
builder: (context, controller, focusNode) {
114114
return customTextField != null
115115
? customTextField.copyWith(
116-
enabled: state.enabled,
117-
controller: controller,
118-
focusNode: focusNode,
119-
decoration: state.decoration,
120-
style:
121-
state.enabled
122-
? customTextField.style
123-
: theme.textTheme.titleMedium!.copyWith(
116+
enabled: state.enabled,
117+
controller: controller,
118+
focusNode: focusNode,
119+
decoration: state.decoration,
120+
style: state.enabled
121+
? customTextField.style
122+
: theme.textTheme.titleMedium!.copyWith(
124123
color: theme.disabledColor,
125124
),
126-
)
125+
)
127126
: TextField(
128-
enabled: state.enabled,
129-
controller: controller,
130-
focusNode: focusNode,
131-
decoration: state.decoration,
132-
style:
133-
state.enabled
134-
? theme.textTheme.titleMedium
135-
: theme.textTheme.titleMedium!.copyWith(
127+
enabled: state.enabled,
128+
controller: controller,
129+
focusNode: focusNode,
130+
decoration: state.decoration,
131+
style: state.enabled
132+
? theme.textTheme.titleMedium
133+
: theme.textTheme.titleMedium!.copyWith(
136134
color: theme.disabledColor,
137135
),
138-
);
136+
);
139137
},
140138
autoFlipMinHeight: autoFlipMinHeight,
141139
hideKeyboardOnDrag: hideKeyboardOnDrag,
@@ -211,12 +209,11 @@ class FormBuilderTypeAheadState<T>
211209
}
212210

213211
String _getTextString(T? value) {
214-
var text =
215-
value == null
216-
? ''
217-
: widget.selectionToTextTransformer != null
218-
? widget.selectionToTextTransformer!(value)
219-
: value.toString();
212+
var text = value == null
213+
? ''
214+
: widget.selectionToTextTransformer != null
215+
? widget.selectionToTextTransformer!(value)
216+
: value.toString();
220217

221218
return text;
222219
}

lib/src/widgets/touch_spin/touch_spin.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,9 @@ class TouchSpinState extends State<TouchSpin> {
6868
}
6969
}
7070

71-
Color? _spinButtonColor(bool btnDisabled) =>
72-
btnDisabled
73-
? widget.iconDisabledColor ?? Theme.of(context).disabledColor
74-
: widget.iconActiveColor ??
75-
Theme.of(context).textTheme.labelLarge?.color;
71+
Color? _spinButtonColor(bool btnDisabled) => btnDisabled
72+
? widget.iconDisabledColor ?? Theme.of(context).disabledColor
73+
: widget.iconActiveColor ?? Theme.of(context).textTheme.labelLarge?.color;
7674

7775
void _adjustValue(num adjustment) {
7876
num newVal = _value + adjustment;

test/form_builder_tester.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ final _formKey = GlobalKey<FormBuilderState>();
55

66
Widget buildTestableFieldWidget(Widget widget) {
77
return MaterialApp(
8-
home: Scaffold(body: FormBuilder(key: _formKey, child: widget)),
8+
home: Scaffold(
9+
body: FormBuilder(key: _formKey, child: widget),
10+
),
911
);
1012
}
1113

test/form_builder_typeahead_test.dart

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ void main() {
2626
if (query.isNotEmpty) {
2727
var lowercaseQuery = query.toLowerCase();
2828
return options
29-
.where((country) {
30-
return country.toLowerCase().contains(lowercaseQuery);
31-
})
32-
.toList(growable: false)..sort(
33-
(a, b) => a
34-
.toLowerCase()
35-
.indexOf(lowercaseQuery)
36-
.compareTo(b.toLowerCase().indexOf(lowercaseQuery)),
37-
);
29+
.where((country) {
30+
return country.toLowerCase().contains(lowercaseQuery);
31+
})
32+
.toList(growable: false)
33+
..sort(
34+
(a, b) => a
35+
.toLowerCase()
36+
.indexOf(lowercaseQuery)
37+
.compareTo(b.toLowerCase().indexOf(lowercaseQuery)),
38+
);
3839
} else {
3940
return options;
4041
}

test_fixes/fixes_12.0.0.dart

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,20 @@ class MyHomePageState extends State<MyHomePage> {
7474
if (query.isNotEmpty) {
7575
var lowercaseQuery = query.toLowerCase();
7676
return allCountries
77-
.where((country) {
78-
return country.toLowerCase().contains(lowercaseQuery);
79-
})
80-
.toList(growable: false)..sort(
81-
(a, b) => a
82-
.toLowerCase()
83-
.indexOf(lowercaseQuery)
84-
.compareTo(b.toLowerCase().indexOf(lowercaseQuery)),
85-
);
77+
.where((country) {
78+
return country.toLowerCase().contains(
79+
lowercaseQuery,
80+
);
81+
})
82+
.toList(growable: false)
83+
..sort(
84+
(a, b) => a
85+
.toLowerCase()
86+
.indexOf(lowercaseQuery)
87+
.compareTo(
88+
b.toLowerCase().indexOf(lowercaseQuery),
89+
),
90+
);
8691
} else {
8792
return allCountries;
8893
}

0 commit comments

Comments
 (0)