Search code examples
fluttercontainerscarouselswipeswiper.js

Swipe gesture for container widgets


I want to create an Instagram like carousel effect with container widgets inside Flutter. I tried the "swiper_flutter" plugin but could´nt achieve the effect I wanted. You can see the sketch I've made here.

enter image description here

I want it to switch the content by detecting a swipe gesture. I also thought of giving the "cards" an index so it can show the count of the pages on the dots below. But I just can't figure out how to swap the container by detecting a swipe gesture.


Solution

  • You can use PageView and the onPageChanged to re-render after scrolling

    PageView(
            controller: pageController,
            scrollDirection: Axis.horizontal,
            children: {Your items},
            onPageChanged: (int index) => onPressCallback(
                {Your code here}
          )