import 'package:flutter/material.dart'; import 'package:page_transition/page_transition.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // Root of the application @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'GeeksForGeeks', theme: ThemeData( primarySwatch: Colors.blue, ), home: MyHomePage(), onGenerateRoute: (settings) { switch (settings.name) { case '/second': return PageTransition( child: SecondPage( title: '', ), type: PageTransitionType.fade, settings: settings, ); default: return null; } }, ); } } /// Homepage class MyHomePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.greenAccent, appBar: AppBar( title: Text('GeeksForGeeks'), backgroundColor: Colors.green, foregroundColor: Colors.white, ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ TextButton( child: Text('Rotate Transition Button'), onPressed: () { Navigator.push( context, PageTransition( curve: Curves.bounceOut, type: PageTransitionType.rotate, alignment: Alignment.topCenter, child: SecondPage( title: '', ), ), ); }, ), ], ), ), ); } } // Definition of second page class SecondPage extends StatelessWidget { final String title; /// Constructor of the page const SecondPage({super.key, required this.title}); @override Widget build(BuildContext context) { final args = ModalRoute.of(context)!.settings.arguments; return Scaffold( appBar: AppBar( title: Text(args as String? ?? "Page Transition Plugin"), backgroundColor: Colors.blue, foregroundColor: Colors.white, ), body: Center( child: Text('Second Page'), ), ); } }