Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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()),
      );
like image 766
kapil tk Avatar asked Oct 14 '25 11:10

kapil tk


1 Answers

You can use Navigator.push(context) for navigate from one page another using button, like the following:

onPressed: () {
  Navigator.push(
    context,
    MaterialPageRoute(
      builder: (context) => const ScreenDashboard(),
    ),
  );
},
like image 183
Shabbir Rajput Avatar answered Oct 17 '25 05:10

Shabbir Rajput