Is it possible to display different link pages by Navigator.push?


I am developing by flutter for web.

It is currently possible to go from the main page to the profile page, but is it possible to keep those URLs separate?
For example:

Main page : https://

Profile page: https://

When I execute the profilePage() function, Navigator.push will take me to the Profile page.

   void profilePage() {
        builder: (context) => showProfile(),

showProfile is executed with a different dart file to complete the page navigation.

 class showProfile extends StatelessWidget {
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          backgroundColor: Colors.white,
          title: const Center(
            child: Text("Test App",
      body: Container(
        height: double.infinity,
        color: Colors.white,

Currently, the Main page and Profile page have the same URL (https://
Therefore, even if the user types, they cannot jump to the profile page.
My purpose is to go to a different URL in Navigator.

Thank you.


This web site helped my issue.


Write the following code in the main function.

void main() {
    initialRoute: '/',
    routes: {
      '/profile': (context) => ProfilePage(),
    title: "test",
    home: (),

Declare the following in the widget whose URL you want to be " profile" (To be exact, "").

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

And finally, call this.

onPressed: () {


Answered By – Beginner_

Answer Checked By – Katrina (FlutterFixes Volunteer)

Leave a Reply

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