I am currently practicing Bloc state management on Flutter and I'm trying to convert some of my code from using setState to using a cubit following Flutter Bloc state management. My code right now is fairly simple, I have a sin and cos chart that I've taken from fl_chart example 10. The chart uses setState in the initState to generate numbers for a FlSpot List and setState to chart a line graph with these numbers.
I am trying to use a cubit instead. In my cubit_state, I have the values that are in setState:
class Graph2State extends Equatable {
final limitCount;
final List sinPoints;
final xValue;
final step;
//late Timer timer;
const Graph2State({
this.limitCount = 250,
this.sinPoints = const <FlSpot>[],
this.xValue = 0,
this.step = 0.5,
//this.timer =
});
@override
List<Object> get props => [sinPoints, xValue, step, ];
}
I'm not sure if this is correct, and I'm not sure where to start on the cubit_cubit portion of the code and where to put BlocBuilder in the fl_chart code.
Can anyone help unstuck me and guide me in the proper direction?