0

I have a getx Controller and I want to call a certain function and restart UI every time my Controller gets build... I use onStart function to do this

 @override
  get onStart {
    getBalance().then((value) {
      update([1]);
    });
    return super.onStart;
  }

the code is fine if I use it in any other place it is ok but in onStart function, it wont rebuild my widgets Can I use update in OnStart Function at all? is there any better way to achieve this?

Ardeshir ojan
  • 1,914
  • 1
  • 13
  • 36

1 Answers1

0

using GetxController, you need to call your initialization code inside the onInit() method like this:

@override
onInit() {
   getBalance().then((value) {
    update([1]);
   });
super.onInit();
}
Gwhyyy
  • 7,554
  • 3
  • 8
  • 35