class MyController extends GetxController {
var test = 0.obs;
}
in my class widget class, at first, I tried
myController.test++
and I could see updated value on
Obx(() => Text("The value is ${myController.test.value}"))
But when I assign a value using
myController.test = someIntegerValue
GetX doesn't update my Widget...
I want to use String values, and they don't seem to work either...
am I missing something?
Please, provide a reproduce code
class MyController extends GetxController { var test = 0.obs; }in my class widget class, at first, I tried
myController.test++and I could see updated value on
Obx(() => Text("The value is ${myController.test.value}"))But when I assign a value using
myController.test = someIntegerValueGetX doesn't update my Widget...
I want to use String values, and they don't seem to work either...
am I missing something?
would be: myController.test.value = someIntegerValue ? Or am I wrong?
you missed the .value
Remember your variable need to be an Rx.
@Katekko is right. New value needs to be assigned to .value, not to the variable itself.
I think the documentation needs to be updated to use final rather than var as that would help to catch those errors right away because it wouldn't allow reassigning the actual variable. I don't think there's any good reason to use var here.
Exactly same issue here https://github.com/jonataslaw/getx/issues/1191
Trying to reassign the variables rather than .value on it
class MyController extends GetxController { var test = 0.obs; }in my class widget class, at first, I tried
myController.test++
and I could see updated value on
Obx(() => Text("The value is ${myController.test.value}"))
But when I assign a value using
myController.test = someIntegerValue
GetX doesn't update my Widget...
I want to use String values, and they don't seem to work either...
am I missing something?would be:
myController.test.value = someIntegerValue? Or am I wrong?
you missed the.valueRemember you variable need to be an Rx.
OMG... how did I miss that, I'll never know.
Thanks man :D
Most helpful comment
would be:
myController.test.value = someIntegerValue? Or am I wrong?you missed the
.valueRemember your variable need to be an Rx.