import 'package:flutter/material.dart'; void main() { runApp(const MaterialApp( debugShowCheckedModeBanner: false, home: Homepage(), )); } class Homepage extends StatelessWidget { const Homepage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('GeeksForGeeks'), backgroundColor: Colors.green, foregroundColor: Colors.white, ), body: Center( child: ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: Colors.green, ), onPressed: () { // Navigate to Page 2 with a custom transition Navigator.of(context).push(_createRoute()); }, child: const Text( 'Go to Page 2', style: TextStyle( color: Colors.white, ), ), ), ), ); } } // Function to create a custom route with a slide transition Route _createRoute() { return PageRouteBuilder( pageBuilder: (context, animation, secondaryAnimation) => const Page2(), transitionsBuilder: (context, animation, secondaryAnimation, child) { var begin = const Offset(0.0, 1.0); var end = Offset.zero; var curve = Curves.ease; var tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve)); return SlideTransition( position: animation.drive(tween), child: child, ); }, ); } class Page2 extends StatelessWidget { const Page2({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.blue, foregroundColor: Colors.white, ), body: const Center( child: Text('Page 2'), ), ); } }