我推了四个屏幕ScreenOne >> ScreenTwo >> ScreenThree >> ScreenFour
并且我现在在ScreenFour,我想弹出回到[[ScreenTwo
在Swift中,它的工作方式如下::let viewControllers: [UIViewController] = self.navigationController!.viewControllers
for vc in viewControllers
{
if (vc is SecondViewController)
{
self.navigationController!.popToViewController(vc, animated: true)
}
}
如何在颤动中执行此操作。请提供解决方案,谢谢。
Navigator.popUntil(context, ModalRoute.withName('/home'));
Navigator.of(context).pushNamedAndRemoveUntil(
'/BottomNavigation', (Route<dynamic> route) => false);
对于深度阅读,请遵循this
Navigator.of(context).push(
MaterialPageRoute(builder: (_) {
return SecondPage();
},
settings: RouteSettings(name: 'SecondPage',),
));
您需要定义相同的路由名称
Navigator.of(context).popUntil((route){
return route.settings.name == 'SecondPage';
});