您可以使用.pop()
在PageRouteBuilder
上删除动画。另一方面,popUntil
方法只接受谓词作为参数。
如何在没有任何动画的情况下使用.popUntil
方法?
我正在努力实现以下目标
// Pop the view to the root (multiple navigations)
Navigator.of(context).popUntil((route) => route.isFirst);
// Navigate to the new route
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => FooScreen()));
答案 0 :(得分:0)
感谢@ user8773560指出了pushAndRemoveUntil
方法。
这解决了动画问题
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => FooScreen()),
(route) => route.isFirst,
);