如何在弹出窗口中弹出特定屏幕

问题描述 投票:0回答:3

我推了四个屏幕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) } }

如何在颤动中执行此操作。

请提供解决方案,谢谢。

ios swift flutter dart uinavigationcontroller
3个回答
2
投票
您需要在materialApp中定义您的路线,以便Navigator识别。为了使以下代码正常工作,需要在我的MaterialApp中定义“ / home”。

Navigator.popUntil(context, ModalRoute.withName('/home'));


0
投票
Navigator.of(context).pushNamedAndRemoveUntil( '/BottomNavigation', (Route<dynamic> route) => false);

对于深度阅读,请遵循this


0
投票
Navigator.of(context).push( MaterialPageRoute(builder: (_) { return SecondPage(); }, settings: RouteSettings(name: 'SecondPage',), ));

您需要定义相同的路由名称

Navigator.of(context).popUntil((route){
  return route.settings.name == 'SecondPage';
}); 
© www.soinside.com 2019 - 2024. All rights reserved.