I have a Login page, when I log on to go to the main page of my app i am using
Navigator.pushReplacement(context, new MaterialPageRoute(builder: (BuildContext context) => new Page1()));
But it have the slide animation, i want to disable it.
this is my Material app format
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new Login(title: 'Login'),
routes: <String, WidgetBuilder>{
'/screen3': (BuildContext context) => new Page1(),
},
);
}
}
My solution is to define the route with
isInitialRoute:true
. This prevents Flutter from showing an animation when the route is pushed.Here's a working example and screen recording:
You should try to extend MaterialPageRoute and override buildTransitions as follows:
You would need to override the
buildTransitions
method to prevent animations.