Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flutter 底部导航栏 #53

Open
gaowei1012 opened this issue Oct 16, 2020 · 0 comments
Open

flutter 底部导航栏 #53

gaowei1012 opened this issue Oct 16, 2020 · 0 comments

Comments

@gaowei1012
Copy link
Owner

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;
    });
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant