change materialroute flutter code example
Example 1: Flutter Navigator to new page
// Within the `FirstRoute` widget
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondRoute()),
);
}
Example 2: slide left animtion on naviagtor push in flutter
Navigator.push(context, SlideRightRoute(page: Screen2()))
import 'package:flutter/material.dart';class SlideRightRoute extends PageRouteBuilder { final Widget page; SlideRightRoute({this.page}) : super( pageBuilder: ( BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, ) => page, transitionsBuilder: ( BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child, ) => SlideTransition( position: Tween<Offset>( begin: const Offset(-1, 0), end: Offset.zero, ).animate(animation), child: child, ), );}