我是 Flutter 的新手,我想以正确的方式做到这一点,问题是我有一个底部导航栏包 i Curved_navigation_bar它有很棒的外观和动画,这个导航栏应该改变 Scaffold 小部件的主体并显示每次一个新的小部件取决于单击的按钮,我想要实现的是每次单击导航栏的按钮时执行以下操作:
- 清除身体
Scaffold
- 加载相关的小部件
我希望这是在颤振导航中遵循的正确方法(更改屏幕或视图),如果这是错误的,请告诉我
class _SituationState extends State<ScreenSituation>{
int _page = 0;
GlobalKey _bottomNavigationKey = GlobalKey();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
//if list button is clicked preveiw widget_client
//if people button is clicked preveiw widget_people
//if launch button is clicked preveiw launch
),
bottomNavigationBar: CurvedNavigationBar(
key: _bottomNavigationKey,
index: 0,
height: 75.0,
items: <Widget>[
Icon(Icons.list, size: 30),
Icon(Icons.people, size: 30),
Icon(Icons.launch, size: 30),
],
color: Colors.white,
buttonBackgroundColor: Colors.white,
backgroundColor: Colors.blueAccent,
animationCurve: Curves.easeInOut,
animationDuration: Duration(milliseconds: 300),
onTap: (index) {
setState(() {
_page = index;
});
},
),
);
}
}