EverFinal88
EverFinal88

Reputation: 108

How to do page view with cross fade animation

I am making a carousel with cross fade animation which I am using AnimatedSwitcher with FadeTransition to achieve such effect. The effect is fine but I want the carousel to be swipeable. I had tried PageView but I do not want the slide animation. Does anyone have any solution to this? Please Help. Thanks in advance.

The custom carousel I currently use.

AnimatedSwitcher(
      duration: const Duration(milliseconds: 500),
      transitionBuilder: (Widget child, Animation<double> animation) {
        return FadeTransition(child: child, opacity: animation);
      },
      child: Image.asset(
        imageList[currentIndex.toInt()],
        key: ValueKey<int>(currentIndex),
      ),

Upvotes: 3

Views: 2288

Answers (1)

WSBT
WSBT

Reputation: 36333

If you do not want slide animation, do not use PageView.

Stick with your current implementation with AnimationSwitcher. If you want to add gesture support, wrap it with GestureDetector and listen on the onHorizontalDrag... or onVerticalDrag... events.

Upvotes: 3

Related Questions