如何使用 flutter go router 返回上一个屏幕?如何弹出上下文?
目前,我只是将一个新屏幕添加到堆栈中,无论我想返回还是前进。
onTap: (() => context.go("/secondPage"))
我用过 context.pop()
但它会抛出错误说 -
_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)
如果您的页面是通过 go_router 呈现的,则可以使用 context.pop()。但如果您使用的是 showModalBottomSheet 或 Dialog 类,那么您应该继续使用 Navigator.pop(context)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)