[英]Using bottom navigator icons and icons in page to navigate to a new screen: Flutter
I am creating an app and in it I have the bottom navigator icons that lead to different screens of the app.我正在创建一个应用程序,其中我有底部导航器图标,这些图标通向应用程序的不同屏幕。
At the same time I want to have icons in the page that lead to the same screen, while showing the bottom navigator icons still, but I can't seem to find my way around it.同时,我希望页面中有指向同一屏幕的图标,同时仍然显示底部导航器图标,但我似乎无法找到解决方法。
On clicking on the in-page icons, I'm led to a new screen but without the bottom navigator icons.单击页面内图标时,我会进入一个新屏幕,但没有底部导航器图标。
Try making list of pages you want to navigate尝试制作要导航的页面列表
int _selectedIndex = 0; //selected page index
List pages=[
Page1(),//current home page
Page2(),
Page3()
];
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
add this inside scaffold body在脚手架体内添加这个
body :_selectedIndex != 0 ? pages[_selectedIndex] :(your body widget)
and inside bottom navigation bar set并在底部导航栏集内
bottomNavigationBar:BottomNavigationBar(
currentIndex: _selectedIndex,
onTap: _onItemTapped
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.