Home > OS >  flutter navigator pushNamed wrong screen
flutter navigator pushNamed wrong screen

Time:05-17

i have 4 screen in order and i created a button with a navigator pushNamed when i press the button to navigate to the second page it"s go to the fourth page and

   return AppBar(
      elevation: 0,
      backgroundColor: Colors.white,
      leading: IconButton(
        icon: Icon(Icons.account_balance, color: Colors.black),
        onPressed: () {
          Navigator.pushNamed(context, MyProfile.screenRoute);
        },
      ),
      title: Text(
        '',
      ),
      titleTextStyle: TextStyle(
        color: Colors.black,
        fontSize: 18,
        fontWeight: FontWeight.bold,
      ),
      centerTitle: true,
      actions: [
        IconButton(
            onPressed: () {}, icon: Icon(Icons.web_sharp, color: Colors.black)),
      ],
    );

when i click the iconbutton it"s navigate to another screen

CodePudding user response:

Check screenRoute value. Probably you forgot to change to myProfile path.

CodePudding user response:

I think your routes are duplicate, Check your screen path and try again

  • Related