Buu Pham
Buu Pham

Reputation: 21

Flutter: Move to a new screen without using navigate

do you have any way to open new screen without using navigation, i want when i open a new screen, the fist stop and play continuous when i go back from the second screen,

i want when i open many creen like the image below, the D creen have a button the button will go back to the A creen, not open new tab A creen

I dont't want it like this:

enter image description here

I want this:

enter image description here

Upvotes: 1

Views: 2395

Answers (2)

Ujjwal Raijada
Ujjwal Raijada

Reputation: 975

There can be 2 ways to this:

  1. You can use Navigator.popUntil since you have to go back to the first screen. This can only be used in case you know how many screens you want to pop.
count = 0;
Navigator.popUntil(context, (route) {
    return count++ == 2;
});
  1. You can also use Navigator.pushReplacementNamed route. Check the link for more reference https://api.flutter.dev/flutter/widgets/Navigator/pushReplacementNamed.html
Navigator.pushReplacementNamed(context, folder/A)

Upvotes: 0

Gobi
Gobi

Reputation: 83

Navigator.of(context).pushAndRemoveUntil(
      MaterialPageRoute(
        builder: (BuildContext context) => A(),
      ),
      (Route route) => false,
    );

Above line help you to achieve your requirement.

Replace A() With your destination class.

Upvotes: 1

Related Questions