美文网首页
Flutter 3.2 BottomNavigationBar

Flutter 3.2 BottomNavigationBar

作者: 贝灬小晖 | 来源:发表于2020-03-09 17:50 被阅读0次

1.BottomNavigationBar
是scaffold组件的参数

就是TabBar~~

type BottomNavigationBarType.fixed 配置底部tabs可以有多个按钮

class HTopMain extends StatefulWidget {
  @override
  _HTopMainState createState() => _HTopMainState();
}

class _HTopMainState extends State<HTopMain> {
  int _currentIndex = 0;
  List homeList = [HomeController(),SetController()];


  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("Wnb"),
        ),
        body: homeList[_currentIndex],
        bottomNavigationBar: BottomNavigationBar(
          items: [BottomNavigationBarItem(
            icon: Icon(
             Icons.cloud 
            ),
            title: Text("首页"),
          ),BottomNavigationBarItem(
            icon: Icon(
             Icons.cloud 
            ),
            title: Text("其他"),
          )],
          currentIndex: this._currentIndex,
          onTap: (int index){
            setState(() {
              this._currentIndex = index;
            });


          },


        ),
      );
  }
}

相关文章

网友评论

      本文标题:Flutter 3.2 BottomNavigationBar

      本文链接:https://www.haomeiwen.com/subject/bczpdhtx.html