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

Question

Asked by Abir A on December 06, 2021 (source).

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 ?

Answer

Question answered by Jahidul I (source).

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

 progress.value = (pro / 100);
ARGUMENTS DOUBLE FLUTTER FLUTTER-GETX TYPES
SHARE: