颤振返回首页 [英] Flutter return to home page

查看:54
本文介绍了颤振返回首页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个具有很多路由的应用程序,一个接一个地推送多个全屏对话框.但是,从一个对话框中,我想关闭所有对话框并返回首页.我该怎么办?

I have made an app that has quite some routing in it, pushing multiple fullscreen dialogs after each other. But from one dialog I want to close all and return to the homepage. How can I do that?

我不想再次推送主页,因为那样,我的导航历史记录中仍然包含所有这些对话框. pushReplacement是正确的方法吗?似乎不是因为它只删除了导航历史记录中的最后一个条目,所以如果我按回去,则会进入倒数第二个对话框...

I don't want to push the homepage again, because then I have all these dialogs still in my navigation history. Is pushReplacement the right way? It doesn't seem to be because it only deletes the last entry in the navigation history, so if i press back, i get to the second last dialog...

推荐答案

使用popUntil返回所需的位置.如果它是主页,则应该可以:

Use popUntil to go back to the point you want. If it's the Home page, this should work:

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

这篇关于颤振返回首页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆