[英]Standard practice when navigating pages using BottomNavigationBar in Flutter?
I am trying to understand the standard practice of using the BottomNavigationBar for navigating/rendering in Flutter.我试图了解在 Flutter 中使用 BottomNavigationBar 进行导航/渲染的标准做法。 I've been looking at examples and have seen multiple ways of doing this.
我一直在查看示例,并看到了多种方法。
Which is the right thing to do or it depends?哪个是正确的事情,或者取决于什么?
It depends on what you want to achieve.这取决于您想要达到的目标。
If you render a new page (with navigate) the page will slide in from right or from wherever you want and you can add a back button to go back to the previous page.如果您呈现一个新页面(带有导航),该页面将从右侧或从您想要的任何位置滑入,您可以将后退按钮添加到 go 回到上一页。
If you use setState to render new content the content will just be replaced.如果您使用 setState 呈现新内容,则内容将被替换。 Therefore it's a completely different user experience.
因此,这是一种完全不同的用户体验。
With a ButtomNavigationBar I suggest to use setState, to just replace the content.使用 ButtonNavigationBar 我建议使用 setState 来替换内容。 This is the usual behavior of a ButtomNavigationBar
这是 ButtonNavigationBar 的通常行为
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.