What about this easy to use
extension WidgetExtensions on Widget {
Page<dynamic> Function(BuildContext, GoRouterState) get transitionPage =>
(context, state) => CustomTransitionPage<dynamic>(
key: state.pageKey,
child: this,
transitionsBuilder: (context, animation, secondaryAnimation, child) {
const begin = Offset(1.0, 0.0);
const end = Offset.zero;
const curve = Curves.easeInOut;
final tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
return SlideTransition(position: animation.drive(tween), child: child);
}
);
}
To use
GoRoute(
path: '/',
pageBuilder: HomeScreen().transitionPage
),