import 'package:flutter/material.dart'; Function pageBuilder = (Widget widget) => ( BuildContext context, Animation animation, Animation secondaryAnimation, ) => widget; Function transitionsBuilder = ( BuildContext context, Animation animation, Animation secondaryAnimation, Widget child, ) { return SlideTransition( position: Tween( begin: const Offset(-1, 0), end: Offset.zero, ).animate(animation), child: Container( decoration: animation.isCompleted ? null : const BoxDecoration( border: Border( right: BorderSide( color: Colors.black, ), ), ), child: child, ), ); }; class SlideRightRoute extends PageRouteBuilder { SlideRightRoute(this.widget) : super( pageBuilder: pageBuilder(widget), transitionsBuilder: transitionsBuilder as Widget Function( BuildContext, Animation, Animation, Widget), ); final Widget widget; }