tunitowen / fancy_bottom_navigation

Flutter plugin - FancyBottomNavigation
Apache License 2.0
773 stars 187 forks source link

How can we keep the bottom navigation on all pages. #41

Open abdulwahid24 opened 5 years ago

abdulwahid24 commented 5 years ago

Currently I have many pages in my app and I want to keep the bottom navigation bar as a permanent widget throughout the app.

Is there any way we can achieve this?

jasonflaherty commented 5 years ago

You can do it like so... each page is held in a list. You might ask this question on stackoverflow for a better response more associated with Flutter UI.

  int _index = 0;
    final List<Widget> _pages = [
      SearchFilterData(),
      SpeakWidget(),
      QAWidget(),
    ];

Widget build(BuildContext context) {
    return Scaffold(
      body: _pages[_index],
      bottomNavigationBar: FancyBottomNavigation(
        tabs: [
          TabData(iconData: Icons.search,title: "Search"),
          TabData(iconData: Icons.language,title: "Speak"),
          TabData(iconData: Icons.question_answer,title: "Q&A"),
        ],
        onTabChangedListener: (position){
          setState(() {
            _index = position;
          });
        },
      ),
    );
  }