Skip to content

Commit 156d760

Browse files
style: apply new dart format
1 parent 693a10d commit 156d760

12 files changed

+489
-425
lines changed

example/lib/main.dart

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,26 @@ class _MyHomePageState extends State<MyHomePage> {
8484
autovalidateMode: AutovalidateMode.onUserInteraction,
8585
min: 1,
8686
max: 100,
87-
validator: (value) => value != null && value < 50 && value > 5
88-
? null
89-
: 'Required value between 5 and 50',
87+
validator:
88+
(value) =>
89+
value != null && value < 50 && value > 5
90+
? null
91+
: 'Required value between 5 and 50',
9092
),
9193
const SizedBox(height: 16),
9294
FormBuilderCupertinoTextField(
9395
name: 'text',
9496
decoration: BoxDecoration(
95-
border: Border.all(
96-
color: CupertinoColors.black,
97-
),
97+
border: Border.all(color: CupertinoColors.black),
9898
borderRadius: BorderRadius.circular(8),
9999
),
100100
autovalidateMode: AutovalidateMode.onUserInteraction,
101-
validator: (value) =>
102-
value != null && value.length > 4 ? null : 'Write a text',
103-
)
101+
validator:
102+
(value) =>
103+
value != null && value.length > 4
104+
? null
105+
: 'Write a text',
106+
),
104107
],
105108
),
106109
),

lib/src/fields/form_builder_cupertino_checkbox.dart

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -152,43 +152,46 @@ class FormBuilderCupertinoCheckbox extends FormBuilderField<bool> {
152152
this.autofocus = false,
153153
this.mouseCursor,
154154
}) : super(
155-
builder: (FormFieldState<bool?> field) {
156-
final state = field as _FormBuilderCupertinoCheckboxState;
157-
158-
final fieldWidget = CupertinoCheckbox(
159-
focusColor: focusColor,
160-
focusNode: state.effectiveFocusNode,
161-
fillColor: fillColor,
162-
value: state.value ?? false,
163-
checkColor: checkColor,
164-
shape: shape,
165-
side: side,
166-
tristate: tristate,
167-
autofocus: autofocus,
168-
mouseCursor: mouseCursor,
169-
semanticLabel: semanticLabel,
170-
onChanged: state.enabled
171-
? (value) {
172-
field.didChange(value);
173-
}
174-
: null,
175-
activeColor: activeColor,
176-
);
177-
return CupertinoFormRow(
178-
error: state.hasError
179-
? errorBuilder != null
180-
? errorBuilder(state.errorText ?? '')
181-
: Text(state.errorText ?? '')
182-
: null,
183-
helper: helper,
184-
padding: contentPadding,
185-
prefix: prefix,
186-
child: shouldExpandedField
187-
? SizedBox(width: double.infinity, child: fieldWidget)
188-
: fieldWidget,
189-
);
190-
},
191-
);
155+
builder: (FormFieldState<bool?> field) {
156+
final state = field as _FormBuilderCupertinoCheckboxState;
157+
158+
final fieldWidget = CupertinoCheckbox(
159+
focusColor: focusColor,
160+
focusNode: state.effectiveFocusNode,
161+
fillColor: fillColor,
162+
value: state.value ?? false,
163+
checkColor: checkColor,
164+
shape: shape,
165+
side: side,
166+
tristate: tristate,
167+
autofocus: autofocus,
168+
mouseCursor: mouseCursor,
169+
semanticLabel: semanticLabel,
170+
onChanged:
171+
state.enabled
172+
? (value) {
173+
field.didChange(value);
174+
}
175+
: null,
176+
activeColor: activeColor,
177+
);
178+
return CupertinoFormRow(
179+
error:
180+
state.hasError
181+
? errorBuilder != null
182+
? errorBuilder(state.errorText ?? '')
183+
: Text(state.errorText ?? '')
184+
: null,
185+
helper: helper,
186+
padding: contentPadding,
187+
prefix: prefix,
188+
child:
189+
shouldExpandedField
190+
? SizedBox(width: double.infinity, child: fieldWidget)
191+
: fieldWidget,
192+
);
193+
},
194+
);
192195

193196
@override
194197
FormBuilderFieldState<FormBuilderCupertinoCheckbox, bool> createState() =>

lib/src/fields/form_builder_cupertino_segmented_control.dart

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -99,45 +99,46 @@ class FormBuilderCupertinoSegmentedControl<T extends Object>
9999
this.contentPadding,
100100
this.prefix,
101101
}) : super(
102-
builder: (FormFieldState<T?> field) {
103-
final state =
104-
field as _FormBuilderCupertinoSegmentedControlState<T>;
105-
final theme = CupertinoTheme.of(state.context);
106-
107-
final fieldWidget = CupertinoSegmentedControl<T>(
108-
borderColor: borderColor ?? theme.primaryColor,
109-
selectedColor: selectedColor ?? theme.primaryColor,
110-
pressedColor: pressedColor ?? theme.primaryColor,
111-
groupValue: state.value,
112-
children: <T, Widget>{
113-
for (final option in options) option.value: option,
114-
},
115-
padding: padding,
116-
unselectedColor: unselectedColor,
117-
onValueChanged: (value) {
118-
state.enabled ? field.didChange(value) : field.reset();
119-
},
120-
);
121-
122-
return CupertinoFormRow(
123-
error: state.hasError
124-
? errorBuilder != null
125-
? errorBuilder(state.errorText ?? '')
126-
: Text(state.errorText ?? '')
127-
: null,
128-
helper: helper,
129-
padding: contentPadding,
130-
prefix: prefix,
131-
child: shouldExpandedField
132-
? SizedBox(width: double.infinity, child: fieldWidget)
133-
: fieldWidget,
134-
);
135-
},
136-
);
102+
builder: (FormFieldState<T?> field) {
103+
final state = field as _FormBuilderCupertinoSegmentedControlState<T>;
104+
final theme = CupertinoTheme.of(state.context);
105+
106+
final fieldWidget = CupertinoSegmentedControl<T>(
107+
borderColor: borderColor ?? theme.primaryColor,
108+
selectedColor: selectedColor ?? theme.primaryColor,
109+
pressedColor: pressedColor ?? theme.primaryColor,
110+
groupValue: state.value,
111+
children: <T, Widget>{
112+
for (final option in options) option.value: option,
113+
},
114+
padding: padding,
115+
unselectedColor: unselectedColor,
116+
onValueChanged: (value) {
117+
state.enabled ? field.didChange(value) : field.reset();
118+
},
119+
);
120+
121+
return CupertinoFormRow(
122+
error:
123+
state.hasError
124+
? errorBuilder != null
125+
? errorBuilder(state.errorText ?? '')
126+
: Text(state.errorText ?? '')
127+
: null,
128+
helper: helper,
129+
padding: contentPadding,
130+
prefix: prefix,
131+
child:
132+
shouldExpandedField
133+
? SizedBox(width: double.infinity, child: fieldWidget)
134+
: fieldWidget,
135+
);
136+
},
137+
);
137138

138139
@override
139140
FormBuilderFieldState<FormBuilderCupertinoSegmentedControl<T>, T>
140-
createState() => _FormBuilderCupertinoSegmentedControlState();
141+
createState() => _FormBuilderCupertinoSegmentedControlState();
141142
}
142143

143144
class _FormBuilderCupertinoSegmentedControlState<T extends Object>

lib/src/fields/form_builder_cupertino_slider.dart

Lines changed: 61 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -187,67 +187,69 @@ class FormBuilderCupertinoSlider extends FormBuilderField<double> {
187187
this.contentPadding,
188188
this.prefix,
189189
}) : super(
190-
builder: (FormFieldState<double?> field) {
191-
final state = field as _FormBuilderCupertinoSliderState;
192-
final effectiveNumberFormat =
193-
numberFormat ?? NumberFormat.compact();
190+
builder: (FormFieldState<double?> field) {
191+
final state = field as _FormBuilderCupertinoSliderState;
192+
final effectiveNumberFormat = numberFormat ?? NumberFormat.compact();
194193

195-
final fieldWidget = Column(
196-
mainAxisSize: MainAxisSize.min,
197-
crossAxisAlignment: CrossAxisAlignment.end,
198-
children: [
199-
SizedBox(
200-
width: double.infinity,
201-
child: CupertinoSlider(
202-
value: field.value!,
203-
min: min,
204-
max: max,
205-
divisions: divisions,
206-
activeColor: activeColor,
207-
onChangeEnd: onChangeEnd,
208-
onChangeStart: onChangeStart,
209-
onChanged: state.enabled
210-
? (value) {
211-
field.didChange(value);
212-
}
213-
: null,
214-
thumbColor: thumbColor,
215-
),
216-
),
217-
Row(
218-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
219-
children: <Widget>[
220-
if (displayValues != DisplayValues.none &&
221-
displayValues != DisplayValues.current)
222-
minValueWidget?.call(effectiveNumberFormat.format(min)) ??
223-
Text(effectiveNumberFormat.format(min)),
224-
if (displayValues != DisplayValues.none &&
225-
displayValues != DisplayValues.minMax)
226-
valueWidget?.call(
227-
effectiveNumberFormat.format(field.value)) ??
228-
Text(effectiveNumberFormat.format(field.value)),
229-
if (displayValues != DisplayValues.none &&
230-
displayValues != DisplayValues.current)
231-
maxValueWidget?.call(effectiveNumberFormat.format(max)) ??
232-
Text(effectiveNumberFormat.format(max)),
233-
],
234-
),
235-
],
236-
);
194+
final fieldWidget = Column(
195+
mainAxisSize: MainAxisSize.min,
196+
crossAxisAlignment: CrossAxisAlignment.end,
197+
children: [
198+
SizedBox(
199+
width: double.infinity,
200+
child: CupertinoSlider(
201+
value: field.value!,
202+
min: min,
203+
max: max,
204+
divisions: divisions,
205+
activeColor: activeColor,
206+
onChangeEnd: onChangeEnd,
207+
onChangeStart: onChangeStart,
208+
onChanged:
209+
state.enabled
210+
? (value) {
211+
field.didChange(value);
212+
}
213+
: null,
214+
thumbColor: thumbColor,
215+
),
216+
),
217+
Row(
218+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
219+
children: <Widget>[
220+
if (displayValues != DisplayValues.none &&
221+
displayValues != DisplayValues.current)
222+
minValueWidget?.call(effectiveNumberFormat.format(min)) ??
223+
Text(effectiveNumberFormat.format(min)),
224+
if (displayValues != DisplayValues.none &&
225+
displayValues != DisplayValues.minMax)
226+
valueWidget?.call(
227+
effectiveNumberFormat.format(field.value),
228+
) ??
229+
Text(effectiveNumberFormat.format(field.value)),
230+
if (displayValues != DisplayValues.none &&
231+
displayValues != DisplayValues.current)
232+
maxValueWidget?.call(effectiveNumberFormat.format(max)) ??
233+
Text(effectiveNumberFormat.format(max)),
234+
],
235+
),
236+
],
237+
);
237238

238-
return CupertinoFormRow(
239-
error: state.hasError
240-
? errorBuilder != null
241-
? errorBuilder(state.errorText ?? '')
242-
: Text(state.errorText ?? '')
243-
: null,
244-
helper: helper,
245-
padding: contentPadding,
246-
prefix: prefix,
247-
child: fieldWidget,
248-
);
249-
},
250-
);
239+
return CupertinoFormRow(
240+
error:
241+
state.hasError
242+
? errorBuilder != null
243+
? errorBuilder(state.errorText ?? '')
244+
: Text(state.errorText ?? '')
245+
: null,
246+
helper: helper,
247+
padding: contentPadding,
248+
prefix: prefix,
249+
child: fieldWidget,
250+
);
251+
},
252+
);
251253

252254
@override
253255
FormBuilderFieldState<FormBuilderCupertinoSlider, double> createState() =>

0 commit comments

Comments
 (0)