serenader2014 / flutter_carousel_slider

A flutter carousel widget, support infinite scroll, and custom child widget.
https://pub.dev/packages/carousel_slider
MIT License
1.55k stars 517 forks source link

'enableInfiniteScroll: false' doesn't work when setState is used in onPageChanged #435

Open ronny-strath opened 2 months ago

ronny-strath commented 2 months ago

Hello, I've encountered an issue where when I try to set the value on a variable using setState inside the onPageChanged call, it causes infinte scroll to be enabled, even though I have enableInfiniteScroll set to 'false'. Am I doing something wrong?

This is my code:

CarouselSlider(
          items: promos,
          options: CarouselOptions(
            height: 150,
            viewportFraction: 0.8,
            enlargeCenterPage: true,
            enableInfiniteScroll: false,
            onPageChanged: (int index, CarouselPageChangedReason reason) {
              print(index);
              setState(() {
                promoIndex = index;
              });
            }
          ),
        ),

Thanks!

kishan-dhankecha commented 2 days ago

Hi @ronny-strath, I am now working to provide support for this package on my own fork. I would like to help you with this issue. Can you please provide full reproducible code sample for this issue.