Created
February 20, 2020 15:46
-
-
Save diefferson/989bcfb1068cb6c65848b9435669baa0 to your computer and use it in GitHub Desktop.
Flutter Slide Transition
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
class MyCustomPageRoute extends MaterialPageRoute { | |
final Widget previousPage; | |
MyCustomPageRoute({this.previousPage, WidgetBuilder builder, RouteSettings settings}) : super(builder: builder, settings: settings); | |
@override | |
Widget buildTransitions(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget currentPage) { | |
Animation<Offset> _slideAnimationPage1 = Tween<Offset>(begin: Offset(0.0, 0.0), end: Offset(-1.0, 0.0)).animate(animation); | |
Animation<Offset> _slideAnimationPage2 = Tween<Offset>(begin: Offset(1.0, 0.0), end: Offset(0.0, 0.0)).animate(animation); | |
return Stack( | |
children: <Widget>[ | |
SlideTransition(position: _slideAnimationPage1, child: previousPage), | |
SlideTransition(position: _slideAnimationPage2, child: currentPage), | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment