0

I have a getx Controller. In it i have declared two variables, which will be updated

var percentageEVS = 0.obs;
 var percentOthers =0.obs;

Im trying to change the values of these variables using the following function

  calculatespentTime(){
    final totalDuration = dashboard[0].duration??0;
    final durationEVS = dashboard[1].duration!.toInt();
     final _percentageEVS = (durationEVS/totalDuration)*100;
     percentageEVS.value = _percentageEVS.toInt() ;
}

How ever I'm not getting the changed values

        final List<ChartData> chartData = [
      ChartData(x: 'Maths', y:_controller.percentageEVS.value.toDouble(), color: Colors.red),
      ChartData(x: 'English', y: 38, color: Colors.blue),
]

How can i get the changed value and pass it to chartData??

Febin Johnson
  • 277
  • 1
  • 6
  • 21

1 Answers1

0

Change the line

ChartData(x: 'Maths', y:_controller.percentageEVS.value.toDouble(), color: Colors.red)

to

Obx(()=>ChartData(x: 'Maths', y:_controller.percentageEVS.value.toDouble(), color: Colors.red))
krishnaacharyaa
  • 14,953
  • 4
  • 49
  • 88