Skip to content

Commit bc9b979

Browse files
style: apply new dart format style
1 parent d3fbc2f commit bc9b979

10 files changed

+402
-350
lines changed

example/lib/main.dart

Lines changed: 80 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ class MyHomePageState extends State<MyHomePage> {
6262
asyncItems: (filter, _) async {
6363
await Future.delayed(const Duration(seconds: 1));
6464
return allCountries
65-
.where((element) => element
66-
.toLowerCase()
67-
.contains(filter.toLowerCase()))
65+
.where(
66+
(element) => element.toLowerCase().contains(
67+
filter.toLowerCase(),
68+
),
69+
)
6870
.toList();
6971
},
7072
decoration: const InputDecoration(
@@ -81,9 +83,11 @@ class MyHomePageState extends State<MyHomePage> {
8183
items: allCountries,
8284
onChanged: _onChanged,
8385
decoration: const InputDecoration(
84-
labelText: 'Searchable Dropdown Offline'),
85-
filterFn: (country, filter) =>
86-
country.toLowerCase().contains(filter.toLowerCase()),
86+
labelText: 'Searchable Dropdown Offline',
87+
),
88+
filterFn:
89+
(country, filter) =>
90+
country.toLowerCase().contains(filter.toLowerCase()),
8791
),
8892
const SizedBox(height: 15),
8993
FormBuilderColorPickerField(
@@ -107,14 +111,16 @@ class MyHomePageState extends State<MyHomePage> {
107111
suggestionsCallback: (query) {
108112
if (query.isNotEmpty) {
109113
var lowercaseQuery = query.toLowerCase();
110-
return allCountries.where((country) {
111-
return country.toLowerCase().contains(lowercaseQuery);
112-
}).toList(growable: false)
113-
..sort((a, b) => a
114+
return allCountries
115+
.where((country) {
116+
return country.toLowerCase().contains(lowercaseQuery);
117+
})
118+
.toList(growable: false)..sort(
119+
(a, b) => a
114120
.toLowerCase()
115121
.indexOf(lowercaseQuery)
116-
.compareTo(
117-
b.toLowerCase().indexOf(lowercaseQuery)));
122+
.compareTo(b.toLowerCase().indexOf(lowercaseQuery)),
123+
);
118124
} else {
119125
return allCountries;
120126
}
@@ -140,9 +146,7 @@ class MyHomePageState extends State<MyHomePage> {
140146
onChanged: _onChanged,
141147
),
142148
FormBuilderSignaturePad(
143-
decoration: const InputDecoration(
144-
labelText: 'Signature Pad',
145-
),
149+
decoration: const InputDecoration(labelText: 'Signature Pad'),
146150
name: 'signature',
147151
border: Border.all(color: Colors.green),
148152
onChanged: _onChanged,
@@ -447,32 +451,68 @@ const allCountries = [
447451
'Yemen',
448452
'Yugoslavia',
449453
'Zambia',
450-
'Zimbabwe'
454+
'Zimbabwe',
451455
];
452456

453457
const contacts = <Contact>[
454-
Contact('Andrew', '[email protected]',
455-
'https://d2gg9evh47fn9z.cloudfront.net/800px_COLOURBOX4057996.jpg'),
456-
Contact('Paul', '[email protected]',
457-
'https://media.istockphoto.com/photos/man-with-crossed-arms-isolated-on-gray-background-picture-id1171169099'),
458-
Contact('Fred', '[email protected]',
459-
'https://media.istockphoto.com/photos/confident-businessman-posing-in-the-office-picture-id891418990'),
460-
Contact('Brian', '[email protected]',
461-
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png'),
462-
Contact('John', '[email protected]',
463-
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png'),
464-
Contact('Thomas', '[email protected]',
465-
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png'),
466-
Contact('Nelly', '[email protected]',
467-
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png'),
468-
Contact('Marie', '[email protected]',
469-
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png'),
470-
Contact('Charlie', '[email protected]',
471-
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png'),
472-
Contact('Diana', '[email protected]',
473-
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png'),
474-
Contact('Ernie', '[email protected]',
475-
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png'),
476-
Contact('Gina', '[email protected]',
477-
'https://media.istockphoto.com/photos/all-set-for-a-productive-night-ahead-picture-id637233964'),
458+
Contact(
459+
'Andrew',
460+
461+
'https://d2gg9evh47fn9z.cloudfront.net/800px_COLOURBOX4057996.jpg',
462+
),
463+
Contact(
464+
'Paul',
465+
466+
'https://media.istockphoto.com/photos/man-with-crossed-arms-isolated-on-gray-background-picture-id1171169099',
467+
),
468+
Contact(
469+
'Fred',
470+
471+
'https://media.istockphoto.com/photos/confident-businessman-posing-in-the-office-picture-id891418990',
472+
),
473+
Contact(
474+
'Brian',
475+
476+
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png',
477+
),
478+
Contact(
479+
'John',
480+
481+
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png',
482+
),
483+
Contact(
484+
'Thomas',
485+
486+
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png',
487+
),
488+
Contact(
489+
'Nelly',
490+
491+
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png',
492+
),
493+
Contact(
494+
'Marie',
495+
496+
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png',
497+
),
498+
Contact(
499+
'Charlie',
500+
501+
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png',
502+
),
503+
Contact(
504+
'Diana',
505+
506+
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png',
507+
),
508+
Contact(
509+
'Ernie',
510+
511+
'https://upload.wikimedia.org/wikipedia/commons/7/7c/Profile_avatar_placeholder_large.png',
512+
),
513+
Contact(
514+
'Gina',
515+
516+
'https://media.istockphoto.com/photos/all-set-for-a-productive-night-ahead-picture-id637233964',
517+
),
478518
];

lib/src/fields/form_builder_color_picker.dart

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -114,64 +114,66 @@ class FormBuilderColorPickerField extends FormBuilderFieldDecoration<Color> {
114114
this.colorPreviewBuilder,
115115
this.availableColors = const [],
116116
}) : super(
117-
builder: (FormFieldState<Color?> field) {
118-
final state = field as FormBuilderColorPickerFieldState;
119-
return TextField(
120-
style: style,
121-
decoration: state.decoration.copyWith(
122-
suffixIcon: colorPreviewBuilder != null
123-
? colorPreviewBuilder(field.value)
124-
: LayoutBuilder(
125-
key: ObjectKey(state.value),
126-
builder: (context, constraints) {
127-
return Icon(
128-
Icons.circle,
129-
key: ObjectKey(state.value),
130-
size: constraints.minHeight,
131-
color: state.value,
132-
);
133-
},
134-
),
135-
),
136-
enabled: state.enabled,
137-
readOnly: readOnly,
138-
controller: state._effectiveController,
139-
focusNode: state.effectiveFocusNode,
140-
textAlign: textAlign,
141-
autofocus: autofocus,
142-
expands: expands,
143-
scrollPadding: scrollPadding,
144-
autocorrect: autocorrect,
145-
textCapitalization: textCapitalization,
146-
keyboardType: keyboardType,
147-
obscureText: obscureText,
148-
buildCounter: buildCounter,
149-
cursorColor: cursorColor,
150-
cursorRadius: cursorRadius,
151-
cursorWidth: cursorWidth,
152-
enableInteractiveSelection: enableInteractiveSelection,
153-
inputFormatters: inputFormatters,
154-
keyboardAppearance: keyboardAppearance,
155-
maxLength: maxLength,
156-
maxLengthEnforcement: maxLengthEnforcement,
157-
maxLines: maxLines,
158-
minLines: minLines,
159-
onEditingComplete: onEditingComplete,
160-
showCursor: showCursor,
161-
strutStyle: strutStyle,
162-
textDirection: textDirection,
163-
textInputAction: textInputAction,
164-
);
165-
},
166-
);
117+
builder: (FormFieldState<Color?> field) {
118+
final state = field as FormBuilderColorPickerFieldState;
119+
return TextField(
120+
style: style,
121+
decoration: state.decoration.copyWith(
122+
suffixIcon:
123+
colorPreviewBuilder != null
124+
? colorPreviewBuilder(field.value)
125+
: LayoutBuilder(
126+
key: ObjectKey(state.value),
127+
builder: (context, constraints) {
128+
return Icon(
129+
Icons.circle,
130+
key: ObjectKey(state.value),
131+
size: constraints.minHeight,
132+
color: state.value,
133+
);
134+
},
135+
),
136+
),
137+
enabled: state.enabled,
138+
readOnly: readOnly,
139+
controller: state._effectiveController,
140+
focusNode: state.effectiveFocusNode,
141+
textAlign: textAlign,
142+
autofocus: autofocus,
143+
expands: expands,
144+
scrollPadding: scrollPadding,
145+
autocorrect: autocorrect,
146+
textCapitalization: textCapitalization,
147+
keyboardType: keyboardType,
148+
obscureText: obscureText,
149+
buildCounter: buildCounter,
150+
cursorColor: cursorColor,
151+
cursorRadius: cursorRadius,
152+
cursorWidth: cursorWidth,
153+
enableInteractiveSelection: enableInteractiveSelection,
154+
inputFormatters: inputFormatters,
155+
keyboardAppearance: keyboardAppearance,
156+
maxLength: maxLength,
157+
maxLengthEnforcement: maxLengthEnforcement,
158+
maxLines: maxLines,
159+
minLines: minLines,
160+
onEditingComplete: onEditingComplete,
161+
showCursor: showCursor,
162+
strutStyle: strutStyle,
163+
textDirection: textDirection,
164+
textInputAction: textInputAction,
165+
);
166+
},
167+
);
167168

168169
@override
169170
FormBuilderColorPickerFieldState createState() =>
170171
FormBuilderColorPickerFieldState();
171172
}
172173

173-
class FormBuilderColorPickerFieldState extends FormBuilderFieldDecorationState<
174-
FormBuilderColorPickerField, Color> {
174+
class FormBuilderColorPickerFieldState
175+
extends
176+
FormBuilderFieldDecorationState<FormBuilderColorPickerField, Color> {
175177
late TextEditingController _effectiveController;
176178

177179
String? get valueString => value?.toHex();
@@ -206,9 +208,7 @@ class FormBuilderColorPickerFieldState extends FormBuilderFieldDecorationState<
206208

207209
return AlertDialog(
208210
// title: null, //const Text('Pick a color!'),
209-
content: SingleChildScrollView(
210-
child: _buildColorPicker(),
211-
),
211+
content: SingleChildScrollView(child: _buildColorPicker()),
212212
actions: <Widget>[
213213
TextButton(
214214
onPressed: () => Navigator.pop(context, false),

lib/src/fields/form_builder_rating_bar.dart

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -125,44 +125,45 @@ class FormBuilderRatingBar extends FormBuilderFieldDecoration<double> {
125125
this.updateOnDrag = false,
126126
this.wrapAlignment = WrapAlignment.start,
127127
}) : super(
128-
builder: (FormFieldState<double?> field) {
129-
final state = field as FormBuilderRatingBarState;
130-
final widget = state.widget;
131-
132-
return InputDecorator(
133-
decoration: state.decoration,
134-
child: RatingBar(
135-
initialRating: field.value ?? widget.minRating,
136-
minRating: widget.minRating,
137-
direction: widget.direction,
138-
allowHalfRating: widget.allowHalfRating,
139-
itemCount: widget.itemCount,
140-
itemPadding: widget.itemPadding,
141-
// itemBuilder: widget.itemBuilder
142-
onRatingUpdate: (rating) {
143-
field.didChange(rating);
144-
},
145-
ratingWidget: widget.ratingWidget ??
146-
RatingWidget(
147-
full: const Icon(Icons.star),
148-
half: const Icon(Icons.star_half_outlined),
149-
empty: const Icon(Icons.star_outline),
150-
),
151-
glow: widget.glow,
152-
glowColor: widget.glowColor,
153-
glowRadius: widget.glowRadius,
154-
ignoreGestures: !state.enabled,
155-
itemSize: widget.itemSize,
156-
maxRating: widget.maxRating,
157-
tapOnlyMode: widget.tapOnlyMode,
158-
textDirection: widget.textDirection,
159-
unratedColor: widget.unratedColor,
160-
updateOnDrag: widget.updateOnDrag,
161-
wrapAlignment: widget.wrapAlignment,
162-
),
163-
);
164-
},
165-
);
128+
builder: (FormFieldState<double?> field) {
129+
final state = field as FormBuilderRatingBarState;
130+
final widget = state.widget;
131+
132+
return InputDecorator(
133+
decoration: state.decoration,
134+
child: RatingBar(
135+
initialRating: field.value ?? widget.minRating,
136+
minRating: widget.minRating,
137+
direction: widget.direction,
138+
allowHalfRating: widget.allowHalfRating,
139+
itemCount: widget.itemCount,
140+
itemPadding: widget.itemPadding,
141+
// itemBuilder: widget.itemBuilder
142+
onRatingUpdate: (rating) {
143+
field.didChange(rating);
144+
},
145+
ratingWidget:
146+
widget.ratingWidget ??
147+
RatingWidget(
148+
full: const Icon(Icons.star),
149+
half: const Icon(Icons.star_half_outlined),
150+
empty: const Icon(Icons.star_outline),
151+
),
152+
glow: widget.glow,
153+
glowColor: widget.glowColor,
154+
glowRadius: widget.glowRadius,
155+
ignoreGestures: !state.enabled,
156+
itemSize: widget.itemSize,
157+
maxRating: widget.maxRating,
158+
tapOnlyMode: widget.tapOnlyMode,
159+
textDirection: widget.textDirection,
160+
unratedColor: widget.unratedColor,
161+
updateOnDrag: widget.updateOnDrag,
162+
wrapAlignment: widget.wrapAlignment,
163+
),
164+
);
165+
},
166+
);
166167

167168
@override
168169
FormBuilderRatingBarState createState() => FormBuilderRatingBarState();

0 commit comments

Comments
 (0)