我希望创建一个具有底部导航视图的应用程序。如何实现这一点?我看到了一些youtube视频,但没有任何结果。
答案 0 :(得分:2)
您可以使用BottomNavigationBar here作为文档:
你可以像这样实现BottomNavigation。
class BottomBar extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return new _BottomBarState();
}
}
class _BottomBarState extends State<BottomBar> with SingleTickerProviderStateMixin {
TabController tabController;
//here in the initstate we assign the tabcontroller and give it a length and vsyc for animation.
@override
void initState() {
super.initState();
tabController = new TabController(initialIndex: 1,length: 3, vsync: this);
}
//dispose method for good practice.
@override
void dispose() {
super.dispose();
tabController.dispose();
}
//our build widget of state class.
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('bottomNavigation'),
),
bottomNavigationBar: new Material(
child: new TabBar(
controller: tabController,
tabs: <Widget>[
new Tab(
child: new Icon(Icons.star),
),
new Tab(
child: new Icon(Icons.favorite),
),
new Tab(
child: new Icon(Icons.headset),
),
],
),
)); //scaffold
}
}
答案 1 :(得分:0)
对于像底部导航抽屉等小部件,请查看此回购..
演示材料设计窗口小部件的应用程序以及Flutter提供的其他功能。 https://github.com/flutter/flutter/tree/master/examples/flutter_gallery