0

I have a screen that I'd put all body in an Obx , I have a widget that has a parameter named activeIndex like this

AnimatedSmoothIndicator(
    activeIndex: homeController.carouselPage.value,
    count: homeController.posts[index].images.length,
    effect: WormEffect(),
  ),

carouselPage parameter give it's value in controller like this

RxInt carouselPage = 0.obs;

    SetCarouselIndex(int index) {
        carouselPage.value = index;
      }

SetCarouselIndex fires and the value changes but the UI not change . What is the problem ?

mm sh
  • 192
  • 3
  • 18

2 Answers2

0
final carouselPage = 0.obs;

// on this part actually lacking a update();
SetCarouselIndex(int? index) {
carouselPage.value = index;
update();
}

so other thing to update also like this

SetCarouselIndex(int? index) {
carouselPage(index!);
}
Arbiter Chil
  • 1,061
  • 1
  • 6
  • 9
0
    You can use 
    var carouselPage = 0.obs;

    instead of
    RxInt carouselPage = 0.obs;

    SetCarouselIndex(int index) {
      carouselPage.value = index
    }

    Obx(()=>
      AnimatedSmoothIndicator(
        activeIndex: homeController.carouselPage.value,
        count: homeController.posts[index].images.length,
        effect: WormEffect(),
    ),)