0

I am using Flutter with GetX plugin and I have three radio buttons inside statelesswidget but the radio button doesn't changed to selected when user click on it so my question is how I can update the selected radio using GetX plugin. here is my code

                  activeColor: mainColor1,
                  materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
                  // checkColor: Colors.white,
                  value: isSelected,
                  onChanged: (value) {
                    print('=====');
                    setState(() {
                      isSelected = value;
                      widget.onPress(value);
                    });
            })
          ), 

and here is my controller side


  changeStatus(String select, bool condition) {

    if (condition) {
      selected.add(select);
    } else {
      selected.remove(select);
    }
    print(selected.length);
    update();
  }

1 Answers1

0

you have to initialize your controller like this:

final Controller _controller = Get.put(Controller());

call your method like this in onChanged:

_controller.your method

& put the whole dropdown widget in:

Obx(()=>DropdownButton)
helvete
  • 2,455
  • 13
  • 33
  • 37