Last active
March 5, 2021 19:11
-
-
Save lecuseasar/628663a17f991fbaf1ef620cc0dfb0f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Material App', | |
home: Page1(), | |
); | |
} | |
} | |
class Page1 extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Material App Bar'), | |
), | |
body: Center( | |
child: ElevatedButton( | |
onPressed: () { | |
Navigator.of(context).push(_createRoute()); | |
}, | |
child: Text('Next'), | |
), | |
), | |
); | |
} | |
} | |
class Page2 extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(), | |
body: Center( | |
child: Text('Page 2'), | |
), | |
); | |
} | |
} | |
Route _createRoute() { | |
return PageRouteBuilder( | |
pageBuilder: (context, animation, secondaryAnimation) => Page2(), | |
transitionsBuilder: (context, animation, secondaryAnimation, child) { | |
// * change | |
var begin = Offset(0.0, 1.0); | |
var end = Offset.zero; | |
// * change | |
var curve = Curves.easeInCirc; | |
var tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve)); | |
return SlideTransition( | |
position: animation.drive(tween), | |
child: child, | |
); | |
}, | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment