Meggy
Meggy

Reputation: 1671

Flutter/Dart - Navigator.pop(context) - How to Pop two Contexts back?

I've got;

SwipeGestureRecognizer which calls;

Navigator.push (context,
                  PageTransition(
                    type: PageTransitionType.downToUp,
                    child: HomeReply(),
                  ));

How do I get the Navigator to pop back to Home()?

Upvotes: 0

Views: 4979

Answers (2)

Meggy
Meggy

Reputation: 1671

Turns out HomeReply() had an extra MaterialApp in the build. Once I removed this it all worked as normal with Navigator.pop(context);.

Upvotes: 1

Zeeshan Hussain
Zeeshan Hussain

Reputation: 842

The navigator is a stack so you can use the popUntil method to pop back to your home() screen.

Navigator.popUntil(context, ModalRoute.withName('/home'));

or

Navigator.of(context).popUntil((route) => route.settings.name == "Home");

Upvotes: 1

Related Questions