Search code examples
fluttertypesargumentsdoubleflutter-getx

Flutter Getx : type 'double' is not a subtype of type 'RxDouble'


I am using Getx package on my flutter app. I want to update a double value. but it's show me an error.

here is my gextController

class CustomWebViewCTRL extends GetxController {
 
  RxDouble progress = 0.0.obs;

  onProgress(pro) {
    progress = (pro / 100);
  }
}

And then I am trying to call it on my home screen by Obx(()=>) and GetBuilder also. No one works for me. It's saying -

"The argument type 'RxDouble' can't be assigned to the parameter type 'double?'"

Here is a sample (where I want to use) :

GetBuilder<CustomWebViewCTRL>(builder: (controller) {
            return LinearProgressIndicator(
              value: controller.progress,
              color: Colors.black,
              backgroundColor: Colors.amber,
              valueColor: const AlwaysStoppedAnimation<Color>(Colors.green),
            );
          }),

How can I fixed this ?


Solution

  • When assigning values to Rx Types use-value property.try with this

     progress.value = (pro / 100);