File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change
1
+ import '../utils/get_week.dart' ;
2
+
1
3
class WeeklyData {
2
4
String id;
3
5
int year;
@@ -47,8 +49,15 @@ class WeeklyData {
47
49
}
48
50
49
51
int percentThisWeek (){
52
+ DateTime today = DateTime .now ();
53
+ int thisWeek = getWeek (today);
54
+ double max;
55
+ if (thisWeek== this .week && today.year== this .year){
56
+ max = (dailyTarget* DateTime .now ().weekday).toDouble ();
57
+ }else {
58
+ max = (dailyTarget* 7 ).toDouble ();
59
+ }
50
60
double total = totalThisWeek ();
51
- double max = (dailyTarget* DateTime .now ().weekday).toDouble ();
52
61
return ((total/ max)* 100 ).toInt ();
53
62
}
54
63
}
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ class WeeklyStatisticsGraph extends StatelessWidget {
25
25
}
26
26
}
27
27
for (int i= 1 ;i<= 7 ;i++ ){
28
- double h = maxH* (intakes[i.toString ()]/ max);
28
+ double h = max == 0 ? 0 : maxH* (intakes[i.toString ()]/ max);
29
29
bars.add (
30
30
Column (
31
31
mainAxisSize: MainAxisSize .min,
You can’t perform that action at this time.
0 commit comments