Skip to content

Commit a723812

Browse files
Update more core to Dart 3 ( mostly switching to Iterable.indexed )
Signed-off-by: Erick Howard <needlesslygrim@proton.me>
1 parent c1f33f0 commit a723812

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

lib/components/button.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class _MButtonGroupState extends State<MButtonGroup> {
8181
selected = widget.selected;
8282
return Row(
8383
children: [
84-
for (var i = 0; i < widget.titles.length; i++)
84+
for (final (i, title) in widget.titles.indexed)
8585
RawMaterialButton(
8686
onPressed: () {
8787
setState(() {
@@ -131,7 +131,7 @@ class _MButtonGroupState extends State<MButtonGroup> {
131131
),
132132
),
133133
child: Text(
134-
widget.titles[i],
134+
title,
135135
style: TextStyle(
136136
color: selected == i ? MColors.white : MColors.grey.shade700,
137137
fontSize: 14,
@@ -539,7 +539,7 @@ class _MLongComboDropdownButtonState extends State<MLongComboDropdownButton> {
539539
dropdownStyleData: DropdownStyleData(
540540
scrollbarTheme: ScrollbarThemeData(
541541
// I think this does the right thing...
542-
thumbVisibility: MaterialStateProperty.all(true)
542+
thumbVisibility: WidgetStateProperty.all(true)
543543
),
544544
elevation: 0,
545545
padding: const EdgeInsets.only(bottom: 6),

lib/pages/checkout.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ class CheckoutPage extends StatelessWidget {
1616

1717
@override
1818
Widget build(BuildContext context) {
19+
var checkoutItems = context.watch<CheckoutCN>().items;
1920
return Column(
2021
crossAxisAlignment: CrossAxisAlignment.start,
2122
children: [
2223
Text(
23-
context.watch<CheckoutCN>().items.isEmpty
24+
checkoutItems.isEmpty
2425
? 'Checkout'
25-
: "Checkout - ${context.watch<CheckoutCN>().items.length} item${context.read<CheckoutCN>().items.length == 1 ? '' : 's'}",
26+
: "Checkout - ${checkoutItems.length} item${context.read<CheckoutCN>().items.length == 1 ? '' : 's'}",
2627
style: MTextStyles.dsmMdGrey900,
2728
),
2829
const SizedBox(height: 24),
@@ -38,7 +39,7 @@ class CheckoutPage extends StatelessWidget {
3839
}
3940
},
4041
title: (context.watch<CheckoutCN>().selected.length ==
41-
context.watch<CheckoutCN>().items.length)
42+
checkoutItems.length)
4243
? "Select None"
4344
: "Select All",
4445
),
@@ -52,7 +53,7 @@ class CheckoutPage extends StatelessWidget {
5253
const Spacer(),
5354
MButton(
5455
onPressed: () {
55-
if (context.read<DownloadCN>().downloadPath == '') {
56+
if (context.read<DownloadCN>().downloadPath.isEmpty) {
5657
// show alertdialog
5758
showDialog(
5859
context: context,
@@ -92,21 +93,20 @@ class CheckoutPage extends StatelessWidget {
9293
child: Column(
9394
children: [
9495
const CheckoutTableHeader(),
95-
if (context.watch<CheckoutCN>().items.isEmpty)
96+
if (checkoutItems.isEmpty)
9697
const NoCheckoutPlaceholder(),
97-
for (var i = 0, l = context.watch<CheckoutCN>().items;
98-
i < l.length;
99-
i++) ...[
98+
for (final (i, item) in checkoutItems.indexed)...[
10099
CheckoutEntryRow(
101-
item: l.elementAt(i),
100+
item: item,
102101
documentType: "Document",
103102
isSelected: context
104103
.watch<CheckoutCN>()
105104
.selected
106-
.contains(l.elementAt(i)),
107-
isLast: i == l.length - 1,
105+
.contains(item),
106+
isLast: i == checkoutItems.length - 1,
108107
),
109-
],
108+
]
109+
,
110110
],
111111
),
112112
),

0 commit comments

Comments
 (0)