Skip to content

Commit 7242d6d

Browse files
committed
apply dart quick fixes
1 parent f9c7f50 commit 7242d6d

File tree

2 files changed

+8
-30
lines changed

2 files changed

+8
-30
lines changed

apps/onyx/lib/screens/izly/pages/izly_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class IzlyPage extends StatelessWidget {
7373
children: [
7474
Text(
7575
"${AppLocalizations.of(context).available(state.qrCodeAvailables)} ${AppLocalizations.of(context).offline}"),
76-
IzlyQrcodeWidget(),
76+
const IzlyQrcodeWidget(),
7777
Text(
7878
"${state.balance.toStringAsFixed(2)}€",
7979
style: Theme.of(context).textTheme.bodyLarge!.copyWith(

apps/onyx/lib/screens/izly/widgets/izly_qrcode_widget.dart

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,47 +13,27 @@ class IzlyQrcodeWidget extends StatelessWidget {
1313
const IzlyQrcodeWidget({super.key});
1414

1515
Color calculateWarningColor(BuildContext context) {
16-
if (context
17-
.read<IzlyCubit>()
18-
.state
19-
.paymentList
20-
.isEmpty) {
21-
if (context
22-
.read<IzlyCubit>()
23-
.state
24-
.izlyClient != null &&
25-
context
26-
.read<IzlyCubit>()
27-
.state
28-
.status == IzlyStatus.loaded) {
16+
if (context.read<IzlyCubit>().state.paymentList.isEmpty) {
17+
if (context.read<IzlyCubit>().state.izlyClient != null &&
18+
context.read<IzlyCubit>().state.status == IzlyStatus.loaded) {
2919
context.read<IzlyCubit>().loadPaymentHistory();
3020
}
3121
return Colors.transparent;
3222
}
3323

3424
double average = 0.0;
35-
for (var i in context
36-
.read<IzlyCubit>()
37-
.state
38-
.paymentList) {
25+
for (var i in context.read<IzlyCubit>().state.paymentList) {
3926
if (i.amountSpent < 0) {
4027
average += -i.amountSpent;
4128
}
4229
}
43-
average /= context
44-
.read<IzlyCubit>()
45-
.state
46-
.paymentList
47-
.length;
30+
average /= context.read<IzlyCubit>().state.paymentList.length;
4831

4932
final green = 5 * average; //5 times the average should display green
5033
final red = 2 * average; //2 times the average should display red
5134
//do a linear interpolation between green and red
5235
double interpolation =
53-
(context
54-
.read<IzlyCubit>()
55-
.state
56-
.balance - red) / (green - red);
36+
(context.read<IzlyCubit>().state.balance - red) / (green - red);
5737
return HSVColor.fromAHSV(1, (120 * interpolation).clamp(0, 120), 1, 1)
5838
.toColor();
5939
}
@@ -118,9 +98,7 @@ class IzlyQrcodeWidget extends StatelessWidget {
11898
color: Colors.white,
11999
),
120100
Text(
121-
AppLocalizations
122-
.of(context)
123-
.unHideQrCode,
101+
AppLocalizations.of(context).unHideQrCode,
124102
textAlign: TextAlign.center,
125103
style: const TextStyle(color: Colors.white),
126104
),

0 commit comments

Comments
 (0)