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

Time:12-06

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 ?

CodePudding user response:

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

 progress.value = (pro / 100);
  • Related