Home > Blockchain >  The argument type 'RxInt' can't be assigned to the parameter type 'int'
The argument type 'RxInt' can't be assigned to the parameter type 'int'

Time:01-21

I define 2 RxInt variable in controller class. But when I was calculate sum of two number then I got error: The argument type 'RxInt' can't be assigned to the parameter type 'int'. Bellow my code:

class LogicController extends GetxController {
  RxInt number = 0.obs;
  RxInt thirdNumber = 0.obs;

  void count() {
    number  ;
  }

  void thirdNumberCount() {
    thirdNumber  ;
  }

  addTwoNumber() {
    return  number   thirdNumber; // error 
  }
}

CodePudding user response:

return  number.value   thirdNumber.value;

CodePudding user response:

Just use .value or .toInt() on your RxInt values

  •  Tags:  
  • Related