Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to pop context with FLUTTER go_router?

How do I go back to the previous screen with flutter’s go_router? How to pop context?

Currently I am simply adding a new screen to the stack whether I want to go back or go forward.

 onTap: (() => context.go("/secondPage"))

I have used context.pop() but it throws error saying –

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

_AssertionError ('package:go_router/src/matching.dart': Failed assertion: line 102 pos 9: '_matches.isNotEmpty': You have popped the last page off of the stack, there are no pages left to show)

>Solution :

You can use context.pop() if your page is rendered via go_router. But if you are using showModalBottomSheet or Dialog class then you should continue to use Navigator.pop(context)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading