slide static method

Route slide(
  1. Widget newScreen, {
  2. int direction = 1,
})

Implementation

static Route slide(Widget newScreen, {int direction = 1}) {
  var begin = (direction == slideLeftToRight ? const Offset(
      1.0, 0.0) : const Offset(-1.0, 0.0));
  return PageRouteBuilder(
    pageBuilder: (context, animation, secondaryAnimation) => newScreen,
    transitionsBuilder: (context, animation, secondaryAnimation, child) {
      const end = Offset.zero;
      const curve = Curves.ease;
      var tween = Tween(begin: begin, end: end).chain(
          CurveTween(curve: curve));
      return SlideTransition(
        position: animation.drive(tween),
        child: child,
      );
    },
  );
}