SlideRouteAnimation constructor
SlideRouteAnimation(})
Implementation
SlideRouteAnimation(
this.route, {
this.duration = const Duration(milliseconds: 300),
this.reverseDuration = const Duration(milliseconds: 300),
this.mode = ProsteSlideMode.fromRight,
this.useFade = false,
this.curve = Curves.linear,
}) : super(
pageBuilder: (context, _, __) => route,
transitionDuration: duration,
reverseTransitionDuration: reverseDuration,
transitionsBuilder: (contex, animation, _, child) {
Animation<Offset> position;
switch (mode) {
case ProsteSlideMode.fromRight:
position = Tween<Offset>(begin: Offset(1, 0), end: Offset(0, 0))
.chain(CurveTween(curve: curve))
.animate(animation);
break;
case ProsteSlideMode.fromLeft:
position =
Tween<Offset>(begin: Offset(-1, 0), end: Offset(0, 0))
.chain(CurveTween(curve: curve))
.animate(animation);
break;
case ProsteSlideMode.fromBottom:
position = Tween<Offset>(begin: Offset(0, 1), end: Offset(0, 0))
.chain(CurveTween(curve: curve))
.animate(animation);
break;
case ProsteSlideMode.fromTop:
position =
Tween<Offset>(begin: Offset(0, -1), end: Offset(0, 0))
.chain(CurveTween(curve: curve))
.animate(animation);
break;
}
Widget transitionWidget = SlideTransition(
position: position,
child: child,
);
if (useFade) {
return FadeTransition(
opacity: animation,
child: transitionWidget,
);
}
return transitionWidget;
},
);