Default back button flutter app bring me in login page instead of previous page

71 Views Asked by At

I am developing a flutter application.
When I press the default back button, it brings me to the login page.

Why?

Row(
    children: [
        SizedBox(
            width: 20,
        ),
        Positioned(
            top:10,
            left: 40,
            child: Container(
                height: 80,
                width: 100,
                child: IconButton(
                    onPressed: () {
                        Navigator.pushNamed(context, '/Attendence');
                    },
                    icon: Image.asset('assets/images/attendence.png'),)
            )
        ),

I tried to change Navigator.pushNamed to push but that does not work properly

1

There are 1 best solutions below

0
Eng On

If you push a new route, user can go back. If you push and replace a route, user will not be able to go back.

https://api.flutter.dev/flutter/widgets/Navigator/pushReplacement.html https://api.flutter.dev/flutter/widgets/Navigator/pushReplacementNamed.html