S
S
Stepan2021-09-13 21:21:22
Dart
Stepan, 2021-09-13 21:21:22

How to pass data to another window and forbid going back?

I have 2 windows. The first one is, for example, loginScreen() . In it, I want to go to the second mainScreen() window and pass data there:

Navigator.push(
    context,
    MaterialPageRoute(
        builder: (context) => MainScreen(token: "qwerty"),
    )
);

But because of Navigator.push , a back button appears on the top left.
613f965629283487895447.png
I read that this button can be removed using
AppBar(
    automaticallyImplyLeading: false
)

But then when you press the hardware back button, it still returns to the first loginScreen() window. How do I change the window then?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Neonoviiwolf, 2021-09-14
@Stepashka20

use pushReplacement instead of push
then automaticallyImplyLeading: false is not needed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question