gaowei1012 / blog

this is blog
2 stars 0 forks source link

flutter 底部导航栏 #53

Open gaowei1012 opened 4 years ago

gaowei1012 commented 4 years ago
int _currentIndex = 1;
  List<Widget> list = List();

  @override
  void initState() {
    list..add(HomePage())..add(AboutPage())..add(SettingPage());
    super.initState();
  }

/// 底部 bottom
      bottomNavigationBar: BottomNavigationBar(
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
          BottomNavigationBarItem(icon: Icon(Icons.search), label: 'Search'),
          BottomNavigationBarItem(
              icon: Icon(Icons.arrow_back_outlined), label: 'About')
        ],
        currentIndex: _currentIndex,
        fixedColor: Colors.blue,
        onTap: _onTap,
      ),
body: list[_currentIndex],

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