Home > other >  How to pop context with FLUTTER go_router?
How to pop context with FLUTTER go_router?

Time:11-23

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 -

_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)

CodePudding user response:

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)

  • Related