Skip to content

Commit 69ff577

Browse files
authored
Merge pull request #419 from AhmedLSayed9/adopt_dart_3.7_formatter
Adopt Dart 3.7 formatter with trailing commas preserved
2 parents 5f28a39 + 12ed9b7 commit 69ff577

21 files changed

Lines changed: 452 additions & 394 deletions

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ jobs:
4040
melos bootstrap
4141
4242
- name: Verify formatting
43-
# Remove --line-length=100 when upgrading the min dart sdk to at least 3.7
44-
run: melos exec dart format --output=none --set-exit-if-changed --line-length=100 .
43+
run: melos exec dart format --output=none --set-exit-if-changed .
4544

4645
# Consider passing '--fatal-infos' for slightly stricter analysis.
4746
- name: Run flutter analyze

README.md

Lines changed: 92 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,18 @@ Widget build(BuildContext context) {
210210
),
211211
),
212212
items: items
213-
.map((String item) => DropdownItem<String>(
214-
value: item,
215-
height: 40,
216-
child: Text(
217-
item,
218-
style: const TextStyle(
219-
fontSize: 14,
220-
),
213+
.map(
214+
(String item) => DropdownItem<String>(
215+
value: item,
216+
height: 40,
217+
child: Text(
218+
item,
219+
style: const TextStyle(
220+
fontSize: 14,
221221
),
222-
))
222+
),
223+
),
224+
)
223225
.toList(),
224226
valueListenable: valueListenable,
225227
onChanged: (String? value) {
@@ -285,19 +287,21 @@ Widget build(BuildContext context) {
285287
],
286288
),
287289
items: items
288-
.map((String item) => DropdownItem<String>(
289-
value: item,
290-
height: 40,
291-
child: Text(
292-
item,
293-
style: const TextStyle(
294-
fontSize: 14,
295-
fontWeight: FontWeight.bold,
296-
color: Colors.white,
297-
),
298-
overflow: TextOverflow.ellipsis,
290+
.map(
291+
(String item) => DropdownItem<String>(
292+
value: item,
293+
height: 40,
294+
child: Text(
295+
item,
296+
style: const TextStyle(
297+
fontSize: 14,
298+
fontWeight: FontWeight.bold,
299+
color: Colors.white,
299300
),
300-
))
301+
overflow: TextOverflow.ellipsis,
302+
),
303+
),
304+
)
301305
.toList(),
302306
valueListenable: valueListenable,
303307
onChanged: (value) {
@@ -376,19 +380,21 @@ Widget build(BuildContext context) {
376380
),
377381
),
378382
items: items
379-
.map((String item) => DropdownItem<String>(
380-
value: item,
381-
height: 40,
382-
child: Padding(
383-
padding: const EdgeInsets.symmetric(horizontal: 8.0),
384-
child: Text(
385-
item,
386-
style: const TextStyle(
387-
fontSize: 14,
388-
),
383+
.map(
384+
(String item) => DropdownItem<String>(
385+
value: item,
386+
height: 40,
387+
child: Padding(
388+
padding: const EdgeInsets.symmetric(horizontal: 8.0),
389+
child: Text(
390+
item,
391+
style: const TextStyle(
392+
fontSize: 14,
389393
),
390394
),
391-
))
395+
),
396+
),
397+
)
392398
.toList(),
393399
dropdownSeparator: const DropdownSeparator(
394400
height: 4,
@@ -502,22 +508,21 @@ Widget build(BuildContext context) {
502508
return items.map(
503509
(item) {
504510
return ValueListenableBuilder<List<String>>(
505-
valueListenable: multiValueListenable,
506-
builder: (context, multiValue, _) {
507-
return Container(
508-
alignment: AlignmentDirectional.center,
509-
child: Text(
510-
multiValue
511-
.where((item) => item != 'All')
512-
.join(', '),
513-
style: const TextStyle(
514-
fontSize: 14,
515-
overflow: TextOverflow.ellipsis,
516-
),
517-
maxLines: 1,
511+
valueListenable: multiValueListenable,
512+
builder: (context, multiValue, _) {
513+
return Container(
514+
alignment: AlignmentDirectional.center,
515+
child: Text(
516+
multiValue.where((item) => item != 'All').join(', '),
517+
style: const TextStyle(
518+
fontSize: 14,
519+
overflow: TextOverflow.ellipsis,
518520
),
519-
);
520-
});
521+
maxLines: 1,
522+
),
523+
);
524+
},
525+
);
521526
},
522527
).toList();
523528
},
@@ -576,16 +581,18 @@ Widget build(BuildContext context) {
576581
),
577582
),
578583
items: items
579-
.map((item) => DropdownItem(
580-
value: item,
581-
height: 40,
582-
child: Text(
583-
item,
584-
style: const TextStyle(
585-
fontSize: 14,
586-
),
584+
.map(
585+
(item) => DropdownItem(
586+
value: item,
587+
height: 40,
588+
child: Text(
589+
item,
590+
style: const TextStyle(
591+
fontSize: 14,
587592
),
588-
))
593+
),
594+
),
595+
)
589596
.toList(),
590597
valueListenable: valueListenable,
591598
onChanged: (value) {
@@ -970,15 +977,17 @@ Widget build(BuildContext context) {
970977
style: TextStyle(fontSize: 14),
971978
),
972979
items: genderItems
973-
.map((item) => DropdownItem<String>(
974-
value: item,
975-
child: Text(
976-
item,
977-
style: const TextStyle(
978-
fontSize: 14,
979-
),
980+
.map(
981+
(item) => DropdownItem<String>(
982+
value: item,
983+
child: Text(
984+
item,
985+
style: const TextStyle(
986+
fontSize: 14,
980987
),
981-
))
988+
),
989+
),
990+
)
982991
.toList(),
983992
valueListenable: valueListenable,
984993
validator: (value) {
@@ -1102,29 +1111,32 @@ class CustomDropdownButton2 extends StatelessWidget {
11021111
),
11031112
valueListenable: valueListenable,
11041113
items: dropdownItems
1105-
.map((String item) => DropdownItem<String>(
1106-
value: item,
1107-
height: itemHeight ?? 40,
1108-
child: Container(
1109-
alignment: valueAlignment,
1110-
child: Text(
1111-
item,
1112-
overflow: TextOverflow.ellipsis,
1113-
maxLines: 1,
1114-
style: const TextStyle(
1115-
fontSize: 14,
1116-
),
1114+
.map(
1115+
(String item) => DropdownItem<String>(
1116+
value: item,
1117+
height: itemHeight ?? 40,
1118+
child: Container(
1119+
alignment: valueAlignment,
1120+
child: Text(
1121+
item,
1122+
overflow: TextOverflow.ellipsis,
1123+
maxLines: 1,
1124+
style: const TextStyle(
1125+
fontSize: 14,
11171126
),
11181127
),
1119-
))
1128+
),
1129+
),
1130+
)
11201131
.toList(),
11211132
onChanged: onChanged,
11221133
selectedItemBuilder: selectedItemBuilder,
11231134
buttonStyleData: ButtonStyleData(
11241135
height: buttonHeight ?? 40,
11251136
width: buttonWidth ?? 140,
11261137
padding: buttonPadding ?? const EdgeInsets.only(left: 14, right: 14),
1127-
decoration: buttonDecoration ??
1138+
decoration:
1139+
buttonDecoration ??
11281140
BoxDecoration(
11291141
borderRadius: BorderRadius.circular(14),
11301142
border: Border.all(
@@ -1144,7 +1156,8 @@ class CustomDropdownButton2 extends StatelessWidget {
11441156
maxHeight: dropdownHeight ?? 200,
11451157
width: dropdownWidth ?? 140,
11461158
padding: dropdownPadding,
1147-
decoration: dropdownDecoration ??
1159+
decoration:
1160+
dropdownDecoration ??
11481161
BoxDecoration(
11491162
borderRadius: BorderRadius.circular(14),
11501163
),

analysis_options.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ analyzer:
2020
- "**/*.mocks.dart" # Mockito @GenerateMocks
2121

2222
formatter:
23+
# Preserve trailing commas until Dart formatting improves
24+
trailing_commas: preserve
2325
page_width: 100
2426

2527
linter:

melos.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ scripts:
3030
description: Run `flutter analyze` for all packages.
3131

3232
format:
33-
# Remove --line-length=100 when upgrading the min dart sdk to at least 3.7
34-
run: melos exec dart format --line-length=100 .
33+
run: melos exec dart format .
3534
description: Run `dart format` for all packages.
3635

3736
test:select:

packages/dropdown_button2/example/custom_dropdown_button2.dart

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,29 +79,32 @@ class CustomDropdownButton2 extends StatelessWidget {
7979
),
8080
valueListenable: valueListenable,
8181
items: dropdownItems
82-
.map((String item) => DropdownItem<String>(
83-
value: item,
84-
height: itemHeight ?? 40,
85-
child: Container(
86-
alignment: valueAlignment,
87-
child: Text(
88-
item,
89-
overflow: TextOverflow.ellipsis,
90-
maxLines: 1,
91-
style: const TextStyle(
92-
fontSize: 14,
93-
),
82+
.map(
83+
(String item) => DropdownItem<String>(
84+
value: item,
85+
height: itemHeight ?? 40,
86+
child: Container(
87+
alignment: valueAlignment,
88+
child: Text(
89+
item,
90+
overflow: TextOverflow.ellipsis,
91+
maxLines: 1,
92+
style: const TextStyle(
93+
fontSize: 14,
9494
),
9595
),
96-
))
96+
),
97+
),
98+
)
9799
.toList(),
98100
onChanged: onChanged,
99101
selectedItemBuilder: selectedItemBuilder,
100102
buttonStyleData: ButtonStyleData(
101103
height: buttonHeight ?? 40,
102104
width: buttonWidth ?? 140,
103105
padding: buttonPadding ?? const EdgeInsets.only(left: 14, right: 14),
104-
decoration: buttonDecoration ??
106+
decoration:
107+
buttonDecoration ??
105108
BoxDecoration(
106109
borderRadius: BorderRadius.circular(14),
107110
border: Border.all(
@@ -121,7 +124,8 @@ class CustomDropdownButton2 extends StatelessWidget {
121124
maxHeight: dropdownHeight ?? 200,
122125
width: dropdownWidth ?? 140,
123126
padding: dropdownPadding,
124-
decoration: dropdownDecoration ??
127+
decoration:
128+
dropdownDecoration ??
125129
BoxDecoration(
126130
borderRadius: BorderRadius.circular(14),
127131
),

packages/dropdown_button2/example/example.dart

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,21 @@ class _MyHomePageState extends State<MyHomePage> {
6868
],
6969
),
7070
items: items
71-
.map((String item) => DropdownItem<String>(
72-
value: item,
73-
height: 40,
74-
child: Text(
75-
item,
76-
style: const TextStyle(
77-
fontSize: 14,
78-
fontWeight: FontWeight.bold,
79-
color: Colors.white,
80-
),
81-
overflow: TextOverflow.ellipsis,
71+
.map(
72+
(String item) => DropdownItem<String>(
73+
value: item,
74+
height: 40,
75+
child: Text(
76+
item,
77+
style: const TextStyle(
78+
fontSize: 14,
79+
fontWeight: FontWeight.bold,
80+
color: Colors.white,
8281
),
83-
))
82+
overflow: TextOverflow.ellipsis,
83+
),
84+
),
85+
)
8486
.toList(),
8587
valueListenable: valueListenable,
8688
onChanged: (value) {

0 commit comments

Comments
 (0)