gpt4 book ai didi

flutter - 当我通过单击脚手架内的平面按钮导航到其他页面时,底部导航栏消失

转载 作者:行者123 更新时间:2023-12-05 03:45:25 26 4
gpt4 key购买 nike

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: MyNavigationBar(),
);
}
}

class MyNavigationBar extends StatefulWidget {
@override
_MyNavigationBarState createState() => _MyNavigationBarState();
}

class _MyNavigationBarState extends State<MyNavigationBar> {

int _currentIndex = 0;

// all pages
final List<Widget> _children = [
ListScreen(),
HomaPage(),
FourthScreen(),
ThirdScreen(),
];

void OnTappedBar(int index){
setState(() {
_currentIndex = index;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: _children[_currentIndex],
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
selectedItemColor: Colors.black,
unselectedItemColor: Colors.grey,
onTap: OnTappedBar,
currentIndex: _currentIndex,
items: [
BottomNavigationBarItem(icon: Icon(Icons.home), title: Text("accueil")),
BottomNavigationBarItem(icon: Icon(Icons.search), title: Text("recherche")),
BottomNavigationBarItem(icon: Icon(Icons.calendar_today), title: Text("Mess Pass")),
BottomNavigationBarItem(icon: Icon(Icons.person), title: Text("Mon Profil")),
],
),
);
}
}

拜托!谁能告诉我 bottomNavigationBar 是如何出现在所有页面上的。

当我在任何页面上单击 Scaffold 中的 Flat 按钮时,底部应用栏将被隐藏,但是当我使用底部应用栏项目在其他页面上导航时,底部应用栏不会消失。那么我该如何解决这个问题。我希望底部应用栏出现在所有页面上,即使我使用脚手架中的按钮来导航或底部应用栏项目???

最佳答案

你可以使用这个包persistent_bottom_nav_bar实现这种功能

关于flutter - 当我通过单击脚手架内的平面按钮导航到其他页面时,底部导航栏消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65839629/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com