[英]How to jump back to second previous page in flutter
I am making a drawer
in Flutter.我在 Flutter 做一个
drawer
。 And a refer and earn section
in it.还有一个
refer and earn section
。 Now, whenever I click on that, I will be redirected to refer page.现在,每当我点击它时,我都会被重定向到参考页面。 And when I will press back button on
appbar
, I come back to the drawer widget.当我按下
appbar
上的后退按钮时,我会回到抽屉小部件。 This is working fine and accordingly.这工作正常,因此。 Now, I want that whenever I click on back button from refer page, my
drawer
should be closed and I reach to the main screen.现在,我希望每当我从参考页面单击后退按钮时,我的
drawer
应该关闭并且我到达主屏幕。 How should i do it?我该怎么做?
It's referred to go back to the first page where you start.它被称为 go 回到您开始的第一页。 Whether this route is the bottom-most active route on the navigator.
此路线是否是导航器上最底部的活动路线。 If isFirst and isCurrent are both true then this is the only route on the navigator (and isActive will also be true).
如果 isFirst 和 isCurrent 都为真,那么这是导航器上的唯一路线(并且 isActive 也将为真)。
Navigator.of(context).popUntil((route) => route.isFirst);
You can use this below method to navigate back-您可以使用以下方法向后导航 -
Navigator.popUntil(context, (route) => false);
I figured it out.我想到了。 Pretty simple, when I tap, pop the drawer using
Navigator.pop(context)
and then Navigate to the next page.很简单,当我点击时,使用
Navigator.pop(context)
弹出抽屉,然后导航到下一页。 So, when I clicked back arrow, I got to the main/previous screen.因此,当我单击后退箭头时,我进入了主/上一个屏幕。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.