Flutter应用程序:导航到下一屏幕时需要终止屏幕

时间:2018-07-04 06:22:29

标签: android dart flutter flutter-layout

有没有一种方法可以在不将颤动屏幕添加到屏幕堆栈的情况下终止它?就像我们在android中做finish()一样?

2 个答案:

答案 0 :(得分:1)

您可以使用pushReplacement或pushReplacementNamed。

1)使用路线: Navigator.of(context).pushReplacementNamed('/ secondPage');

2)Navigator.pushReplacement(上下文,MaterialPageRoute(builder:(context)=> SecondPage()));

答案 1 :(得分:0)

我认为您要搜索的是 Navigator.of(context).pop()

需要BuildContext context才能获得Navigator

这两个实现执行相同的操作:

Navigator.pop(context);
// is equal to
Navigator.of(context).pop();

这将关闭当前当前路线 以及路线和与活动类似的在Android中。

相关问题