1- I am working on a code that creates a graph and produces a relationship between two variables. 2- But I can't store the data in a list from TextEditingController
class _HomePageState extends State<HomePage> {
// final firstnameController = TextEditingController();
TextEditingController value1 =TextEditingController();
TextEditingController value2 =TextEditingController();
List<Acceleration> data = [
Acceleration('1', value1 ),
Acceleration('2', value2),
Acceleration('3', 40),
Acceleration('4', 30),
Acceleration('5', 20),
Acceleration('june', 33),
Acceleration('july', 22),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Line Chart speadTimeRelation"),
centerTitle: true,
backgroundColor: Colors.green[700],
// brightness: Brightness.dark,
),
body: GetBuilder<HomeControler>(
init: HomeControler(),
builder: (controller) {
return Column(
children: [
TextFormField(
controller: value1,
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 20),
child: SfCartesianChart(
primaryXAxis:const CategoryAxis(),
title:const ChartTitle(text: 'speadTimeRelation Analysis'),
legend: const Legend(isVisible: true,),
tooltipBehavior: TooltipBehavior(enable: true),
series: <LineSeries<Acceleration, String>>[
LineSeries<Acceleration, String>(
dataSource: data,
xValueMapper: (Acceleration speadTimeRelation, _) => speadTimeRelation.time,
yValueMapper: (Acceleration speadTimeRelation, _) => speadTimeRelation.spead,
name: 'speadTimeRelation',
dataLabelSettings: const DataLabelSettings(isVisible: true),
),
],
),
),
],
);
}
),
);
}
}
class Acceleration{
final String time;
final double spead;
Acceleration(this.time, this.spead);
}