@@ -4,19 +4,21 @@ import 'package:flutter/cupertino.dart';
44import 'package:flutter/material.dart' ;
55import 'package:flutter/widgets.dart' ;
66import 'package:open_weather_client/models/weather_data.dart' ;
7+ import 'package:watch_it/watch_it.dart' ;
78import 'package:yaru/yaru.dart' ;
89
9- import '../../build_context_x.dart' ;
1010import '../../../constants.dart' ;
11+ import '../../build_context_x.dart' ;
1112import '../weather_data_x.dart' ;
13+ import '../weather_model.dart' ;
1214
13- class ForeCastChart extends StatelessWidget {
14- const ForeCastChart ({super .key, required this .data});
15-
16- final List <WeatherData > data;
15+ class ForeCastChart extends StatelessWidget with WatchItMixin {
16+ const ForeCastChart ({super .key});
1717
1818 @override
1919 Widget build (BuildContext context) {
20+ final data =
21+ watchPropertyValue ((WeatherModel m) => m.notTodayForecastDaily);
2022 return Center (
2123 child: Container (
2224 margin: kPagePadding,
@@ -32,9 +34,9 @@ class ForeCastChart extends StatelessWidget {
3234 child: BarChart (
3335 BarChartData (
3436 baselineY: 0 ,
35- titlesData: getTitlesData (context),
37+ titlesData: getTitlesData (context, data ),
3638 borderData: borderData,
37- barGroups: barGroups ,
39+ barGroups: getBarGroups (data) ,
3840 gridData: const FlGridData (show: false ),
3941 alignment: BarChartAlignment .spaceAround,
4042 maxY: data.map ((e) => e.temperature.tempMax).max,
@@ -46,7 +48,8 @@ class ForeCastChart extends StatelessWidget {
4648 );
4749 }
4850
49- FlTitlesData getTitlesData (BuildContext context) => FlTitlesData (
51+ FlTitlesData getTitlesData (BuildContext context, List <WeatherData > data) =>
52+ FlTitlesData (
5053 show: true ,
5154 bottomTitles: AxisTitles (
5255 sideTitles: SideTitles (
@@ -142,7 +145,8 @@ class ForeCastChart extends StatelessWidget {
142145 end: Alignment .bottomCenter,
143146 );
144147
145- List <BarChartGroupData > get barGroups => data.mapIndexed (
148+ List <BarChartGroupData > getBarGroups (List <WeatherData > data) =>
149+ data.mapIndexed (
146150 (i, e) {
147151 return BarChartGroupData (
148152 x: i,
0 commit comments