Created
November 26, 2019 16:38
-
-
Save brianegan/739c500931eeae0eb0f95c73e5864ad7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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'; | |
main() { | |
runApp(MaterialApp( | |
home: Page1(), | |
)); | |
} | |
class Page1 extends StatelessWidget { | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(), | |
body: Center( | |
child: RaisedButton( | |
child: Text('Go!'), | |
onPressed: () { | |
Navigator.of(context).push(_createRoute()); | |
}, | |
), | |
), | |
); | |
} | |
} | |
Route _createRoute() { | |
return PageRouteBuilder( | |
pageBuilder: (context, animation, secondaryAnimation) => Page2(), | |
transitionsBuilder: (context, animation, secondaryAnimation, child) { | |
var begin = 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 { | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(), | |
body: Center( | |
child: Text('Page 2'), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment