Open gaowei1012 opened 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; }); }