class HabitSpline extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Consumer<HabitGraphBloc>(
builder: (context, bloc, _) => SfCartesianChart(
margin: EdgeInsets.fromLTRB(0, 0, 0, 0),
legend: Legend(isVisible: false),
plotAreaBorderWidth: 0,
enableAxisAnimation: false,
primaryXAxis: DateTimeAxis(
isVisible: false,
minimum: DateTime.now().add(Duration(hours: 12)),
maximum: DateTime.now().add(Duration(days: 7, hours: 12)),
),
primaryYAxis: NumericAxis(
isVisible: false,
rangePadding: ChartRangePadding.additional,
),
series: <SplineSeries<PointData, DateTime>>[
for (var graph in bloc.loadedGraphs)
SplineSeries<PointData, DateTime>(
isVisible: graph.isVisible,
markerSettings: MarkerSettings(
isVisible: true,
height: 14,
width: 14,
borderWidth: 6,
borderColor: graph.color,
),
width: 10,
color: graph.color,
emptyPointSettings: EmptyPointSettings(
mode: EmptyPointMode.average,
),
// Bind data source
dataSource: graph.points,
xValueMapper: (PointData pointData, _) =>
DateTime.now().add(Duration(days: pointData.index)),
yValueMapper: (PointData pointData, _) => pointData.points,
)
],
),
);
}
}
Here i am loading some graph values and giving them to a SfCartesianChart. All of them are splines , but
some of them are visible and some of them are not. When i setState, suddently all graphs become visible
again. What i want to happen is that spline series, isVisible value, retains its original value when setting state.
I am using a consumer in this example but it happens with a normal constructor also.
I ended up fixing it with this line below the for loop in the splineSeries argument
if (graph.isVisible)
Still i would consider it a bug