Search code examples
flutterdartandroid-intentnavigator

Which is the best way of using navigate function to handle the movements from one page to another


I am an android developer and now learning about flutter development. In flutter navigator is using to move one page to another like intents in android. While I am using navigate, the back is goes to the initial page.

Am using the below code for navigation.

Navigator.of(context).pushReplacement(
        MaterialPageRoute(builder: (c) => widget.user ? Dashboard() : Login()),
      );

Solution

  • Flutter docs suggests using go_router package for Navigation.

    Flutter applications with advanced navigation and routing requirements (such as a web app that uses direct links to each screen, or an app with multiple Navigator widgets) should use a routing package such as go_router that can parse the route path and configure the Navigator whenever the app receives a new deep link.


    Reference questions regarding go_router: