Transfer pages without animation | Navigator.of(context).pushNamed()


I’m using flutter for the web.
The page is transitioning with Navigator.of(context).pushNamed(Home.route);, but the animation is played at this time.
Is it possible to disable this animation?

I wrote the following code in the main() function of main.dart.

initialRoute: '/home',
routes: {
  '/home': (context) => Home(),
  '/profile': (context) => Profile(),

class Home extends StatelessWidget {
  static const String route = '/home';

class Profile extends StatelessWidget {
  static const String route = '/profile';

And as I mentioned earlier, the following code is used to transition the page.


I was able to transition pages without animation by using Navigator.push, but I want to use Navigator.of(context).pushNamed() because the link does not change.

Does anyone know how to disable animation while still using Navigator.of(context).pushNamed()?
Thank you.


I solved this problem.

I didn’t use Navigator.of().pushNamed() but, it is possible to show URL of pages.

first, I removed routes: from MaterialApp() and added onGenerateRoute: like this;

onGenerateRoute: (settings) {
      Widget wid = Home();
      switch ( {
        case "/home":
          wid = Home();
        case "/profile":
          wid = Profile();

      if (wid != null) {
        return PageRouteBuilder(
                settings, // Pass this to make popUntil(), pushNamedAndRemoveUntil(), works
            pageBuilder: (_, __, ___) => wid,
            transitionsBuilder: (_, a, __, c) =>
                FadeTransition(opacity: a, child: c));
      // Unknown route
      return MaterialPageRoute(builder: (_) => Home());

And when you want to move page, just call this;


Answered By – Beginner_

Answer Checked By – Cary Denson (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *