@@ -3,31 +3,31 @@ import 'package:fl_chart/fl_chart.dart';
33import 'package:flutter/material.dart' ;
44import 'package:flutter_bloc/flutter_bloc.dart' ;
55
6- import '../../.. /cubit/assets_cubit.dart' ;
7- import '../../.. /cubit/balances_cubit.dart' ;
8- import '../../.. /cubit/receivables_cubit.dart' ;
9- import '../../.. /cubit/transactions_cubit.dart' ;
10- import '../../.. /util/money_format.dart' ;
11- import '../../.. /util/theme.dart' ;
6+ import 'package:financial_planner_mobile /cubit/assets_cubit.dart' ;
7+ import 'package:financial_planner_mobile /cubit/balances_cubit.dart' ;
8+ import 'package:financial_planner_mobile /cubit/receivables_cubit.dart' ;
9+ import 'package:financial_planner_mobile /cubit/transactions_cubit.dart' ;
10+ import 'package:financial_planner_mobile /util/money_format.dart' ;
11+ import 'package:financial_planner_mobile /util/theme.dart' ;
1212
1313class AnalyticsPage extends StatelessWidget {
1414 const AnalyticsPage ({super .key});
1515
1616 List <FlSpot > generateExpenseSpots (List <dynamic > transactions) {
17- final now = DateTime .now ();
18- final lastWeek = List .generate (7 , (i) => DateTime (now.year, now.month, now.day).subtract (Duration (days: 6 - i)));
17+ var now = DateTime .now ();
18+ var lastWeek = List .generate (7 , (i) => DateTime (now.year, now.month, now.day).subtract (Duration (days: 6 - i)));
1919
2020 // Initialize a map with zeroes for each day
21- final Map <String , double > dailyTotals = {
21+ Map <String , double > dailyTotals = {
2222 for (var day in lastWeek)
2323 "${day .year }-${day .month }-${day .day }" : 0.0 ,
2424 };
2525
2626 for (var tx in transactions) {
2727 if (tx["type" ] != "expense" ) continue ;
2828
29- final date = tx["date" ].toDate ();
30- final dateKey = "${date .year }-${date .month }-${date .day }" ;
29+ var date = tx["date" ].toDate ();
30+ var dateKey = "${date .year }-${date .month }-${date .day }" ;
3131
3232 if (dailyTotals.containsKey (dateKey)) {
3333 dailyTotals[dateKey] = dailyTotals[dateKey]! + tx["value" ];
@@ -37,7 +37,7 @@ class AnalyticsPage extends StatelessWidget {
3737 // Convert to FlSpot
3838 List <FlSpot > spots = [];
3939 for (int i = 0 ; i < lastWeek.length; i++ ) {
40- final key = "${lastWeek [i ].year }-${lastWeek [i ].month }-${lastWeek [i ].day }" ;
40+ var key = "${lastWeek [i ].year }-${lastWeek [i ].month }-${lastWeek [i ].day }" ;
4141 spots.add (FlSpot (i.toDouble (), dailyTotals[key]! ));
4242 }
4343
@@ -174,7 +174,7 @@ class AnalyticsPage extends StatelessWidget {
174174 SizedBox (height: 30 ),
175175 BlocBuilder <TransactionsCubit , List <dynamic >>(
176176 builder: (context, transactions) {
177- final spots = generateExpenseSpots (transactions);
177+ var spots = generateExpenseSpots (transactions);
178178
179179 return SizedBox (
180180 height: 200 ,
@@ -194,7 +194,7 @@ class AnalyticsPage extends StatelessWidget {
194194 int index = value.toInt ();
195195 if (index < 0 || index >= 7 ) return SizedBox .shrink ();
196196
197- final date = DateTime .now ().subtract (Duration (days: 6 - index));
197+ var date = DateTime .now ().subtract (Duration (days: 6 - index));
198198 return Text ("${date .day .toString ().padLeft (2 , '0' )}/${date .month }" , style: TextStyle (color: Colors .white, fontSize: 10 ));
199199 },
200200 ),
@@ -205,7 +205,7 @@ class AnalyticsPage extends StatelessWidget {
205205 reservedSize: 40 ,
206206 getTitlesWidget: (value, meta) {
207207 // Only show actual used Y values
208- final usedY = spots.map ((e) => e.y).toSet ();
208+ var usedY = spots.map ((e) => e.y).toSet ();
209209 if (usedY.contains (value)) {
210210 return Text (value.toInt ().toString (), style: TextStyle (color: Colors .white, fontSize: 12 ));
211211 }
0 commit comments