I have var hasActivatedIndex = false.obs; and
@override
void onInit() {
super.onInit();
ever(hasActivatedIndex, (callback) {
print('hasActivatedIndex !!== $hasActivatedIndex'); // not activated
});
}
with following method I changed hasActivatedIndex true or false, and hope every time this ever() will get this boolean changed state and print something
int updateActivatedIndex({double scrollPy}){
activatedIndex = eventPyList.indexWhere((element) {
if (scrollPy >= element && scrollPy <= element + 20) {
hasActivatedIndex.value = true;
return true;
} else {
hasActivatedIndex.value = false;
showEventCard = false;
return false;
}
});
return activatedIndex;
}
The hasActivatedIndex.value has indeed changed to true or false, but ever() in onInit does not react to this change, why? thanks in advance for the explanation!