How can I create a custom page animation like CupertinoPageTransitionBuilder. There are some work arounds like stacking previous and new screen and building animations that works when you move towards next while popping it shows the last stacked screen once and disappear after few milliseconds.
Any help would be great.
pageTransitionsTheme: const PageTransitionsTheme(
builders: {
TargetPlatform.android: CupertinoPageTransitionsBuilder(), // NOT SO EFFECTIVE EITHER
},
),
Stacking Current and next screen code.
Stack(
overflow: Overflow.visible,
children: <Widget>[
SlideTransition(
position: Tween<Offset>(
begin: const Offset(0.0, 0.0),
end: const Offset(-0.3, 0.0),
).animate(animation),
child: prevPage,
),
SlideTransition(
position: Tween<Offset>(
begin: const Offset(1.0, 0.0),
end: Offset.zero,
).animate(animation),
child: AnimatedBuilder(
animation: animation,
builder: (c, w) {
return Material(
shadowColor: Colors.black,
// elevation: 10.0 * animation.value,
child: nextPage
);
},
),
)
],
its update if you want to create a page transition animation where both the next and previous pages are animated simultaneously during the transition, you can consider using the
PageRouteBuilderwith a custom animation controller. This allows you to control the animations of both pages.Here's an example of how you can achieve this effect:
In this code:
PageRouteBuilderto create a custom page transition.transitionsBuilder, we define twoSlideTransitionwidgets for the incoming and outgoing pages. These transitions move the pages in opposite directions, creating the desired effect.Stackto overlay both pages during the transition.This approach should create a simultaneous animation for both the next and previous pages during the transition. Adjust the
begin,end, andcurvevalues to fine-tune the animation effect to your liking.