kalismeras61 / flutter_page_transition

This is Flutter Page Transition Package
BSD 2-Clause "Simplified" License
471 stars 56 forks source link

[Q] Does this work with namedRoute #20

Closed RemeJuan closed 4 years ago

RemeJuan commented 4 years ago

Firstly thanks, very nice component.

I was wondering if it works with named routes as I don't see any references in the docs.

I use a navigation service to simplify things so I would like to change the transition for the replace logic as the fade will look much nicer than a swipe for a replacement.

  Future<dynamic> replaceWith(String routeName, {dynamic arguments}) {
    return navigatorKey.currentState
        .pushReplacementNamed(routeName, arguments: arguments);
  }

Thanks

kalismeras61 commented 4 years ago

It's working well with named routes. Please read carefully readme file.

Usage predefined routes with RouteSettings

First, define the onGenerateRoute property in the MaterialApp widget like below and in switch cases you can transition to your new routes:

   onGenerateRoute: (settings) {
        switch (settings.name) {
          case '/second':
            return PageTransition(
              child: SecondPage(),
              type: PageTransitionType.scale,
              settings: settings,
            );
            break;
          default:
            return null;
        }
      },

After that you can use your new route like this:

Navigator.pushNamed(context, '/second', arguments: "arguments data"); for more detail you can look example project.

kalismeras61 commented 4 years ago

closed for inactivity.