A beautiful and animated bottom navigation

Overview

Pub Awesome Flutter Widget Tests

Latest compatibility result for Stable channel Latest compatibility result for Beta channel Latest compatibility result for Dev channel



BottomNavyBar

A beautiful and animated bottom navigation. The navigation bar use your current theme, but you are free to customize it.

Preview PageView
FanBottomNavyBar Gif Fix Gif

Customization (Optional)

BottomNavyBar

  • iconSize - the item icon's size
  • items - navigation items, required more than one item and less than six
  • selectedIndex - the current item index. Use this to change the selected item. Default to zero
  • onItemSelected - required to listen when a item is tapped it provide the selected item's index
  • backgroundColor - the navigation bar's background color
  • showElevation - if false the appBar's elevation will be removed
  • mainAxisAlignment - use this property to change the horizontal alignment of the items. It is mostly used when you have ony two items and you want to center the items
  • curve - param to customize the item change's animation
  • containerHeight - changes the Navigation Bar's height

BottomNavyBarItem

  • icon - the icon of this item
  • title - the text that will appear next to the icon when this item is selected
  • activeColor - the active item's background and text color
  • inactiveColor - the inactive item's icon color
  • textAlign - property to change the alignment of the item title

Getting Started

Add the dependency in pubspec.yaml:

dependencies:
  ...
  bottom_navy_bar: ^5.6.0

Basic Usage

Adding the widget

bottomNavigationBar: BottomNavyBar(
   selectedIndex: _selectedIndex,
   showElevation: true, // use this to remove appBar's elevation
   onItemSelected: (index) => setState(() {
              _selectedIndex = index;
              _pageController.animateToPage(index,
                  duration: Duration(milliseconds: 300), curve: Curves.ease);
    }),
   items: [
     BottomNavyBarItem(
       icon: Icon(Icons.apps),
       title: Text('Home'),
       activeColor: Colors.red,
     ),
     BottomNavyBarItem(
         icon: Icon(Icons.people),
         title: Text('Users'),
         activeColor: Colors.purpleAccent
     ),
     BottomNavyBarItem(
         icon: Icon(Icons.message),
         title: Text('Messages'),
         activeColor: Colors.pink
     ),
     BottomNavyBarItem(
         icon: Icon(Icons.settings),
         title: Text('Settings'),
         activeColor: Colors.blue
     ),
   ],
)

Use with PageView and PageController

class _MyHomePageState extends State<MyHomePage> {

  int _currentIndex = 0;
  PageController _pageController;

  @override
  void initState() {
    super.initState();
    _pageController = PageController();
  }

  @override
  void dispose() {
    _pageController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Bottom Nav Bar")),
      body: SizedBox.expand(
        child: PageView(
          controller: _pageController,
          onPageChanged: (index) {
            setState(() => _currentIndex = index);
          },
          children: <Widget>[
            Container(color: Colors.blueGrey,),
            Container(color: Colors.red,),
            Container(color: Colors.green,),
            Container(color: Colors.blue,),
          ],
        ),
      ),
      bottomNavigationBar: BottomNavyBar(
        selectedIndex: _currentIndex,
        onItemSelected: (index) {
          setState(() => _currentIndex = index);
          _pageController.jumpToPage(index);
        },
        items: <BottomNavyBarItem>[
          BottomNavyBarItem(
            title: Text('Item One'),
            icon: Icon(Icons.home)
          ),
          BottomNavyBarItem(
            title: Text('Item Two'),
            icon: Icon(Icons.apps)
          ),
          BottomNavyBarItem(
            title: Text('Item Three'),
            icon: Icon(Icons.chat_bubble)
          ),
          BottomNavyBarItem(
            title: Text('Item Four'),
            icon: Icon(Icons.settings)
          ),
        ],
      ),
    );
  }
}
Comments
  • Swiping through pages work but Changing page through nav bar doesnt bar

    Swiping through pages work but Changing page through nav bar doesnt bar

    Below is the code in my main.dart file, note that swiping behaviour works but the logic of pageController doesn't work.

    class _MyHomePageState extends State<MyHomePage> {
      int _currentIndex = 0;
      PageController _pageController;
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: SafeArea(
            child: PageView(
              controller: _pageController,
              children: <Widget>[
                HomeContent(),
                CalendarContent(),
                AddContent(),
                ProjectsContent(),
                SettingsContent()
              ],
              onPageChanged: (index) {
                setState(() {
                  _currentIndex = index;
                });
              },
            ),
          ),
          bottomNavigationBar: BottomNavyBar(
            selectedIndex: _currentIndex,
            showElevation: true,
            itemCornerRadius: 24,
            curve: Curves.elasticInOut,
            onItemSelected: (index) => setState(() {
              _currentIndex = index;
              _pageController.animateToPage(index,
                  duration: Duration(milliseconds: 300), curve: Curves.ease);
            }),
            items: [
              BottomNavyBarItem(
                icon: Icon(Icons.home),
                title: Text('Home'),
                activeColor: Colors.deepPurple[800],
                inactiveColor: Colors.black45
              ),
              BottomNavyBarItem(
                icon: Icon(Icons.calendar_today_outlined),
                title: Text('Calendar'),
                activeColor: Colors.deepPurple[800],
                inactiveColor: Colors.black45
              ),
              BottomNavyBarItem(
                icon: Icon(Icons.add),
                title: Text('Add'),
                activeColor: Colors.deepPurple[800],
                inactiveColor: Colors.black45
              ),
              BottomNavyBarItem(
                icon: Icon(Icons.work_outline_outlined),
                title: Text('Projects'),
                activeColor: Colors.deepPurple[800],
                inactiveColor: Colors.black45
              ),
              BottomNavyBarItem(
                icon: Icon(Icons.settings),
                title: Text('Settings'),
                activeColor: Colors.deepPurple[800],
                inactiveColor: Colors.black45
              ),
            ],
          )
        );
      }
    }
    

    I tried with both page Controller Jump to page and the animateToPage but it either disables clicking on the items or it doesnt change page and just clicking behaviour works and not page changing one.

    Also I tried with and without SizedBox.expand as parent of Page View but it didn't work.

    I will try to make a new project and try it again to see if its this package problem or not.

    waiting customer response 
    opened by prateekmedia 6
  • Scroll Position

    Scroll Position

    The scroll position of one screen is getting reset after coming back from another. ex: In HomePage i scrolled to bottom and went to another page then went to home page the scroll position is top. Any solution?

    If i want to add newsfeed i need to maintain the scroll position it's necessary. Look into this. Thanks.

    opened by Renatinaveen 4
  • Bar is to low at iPhone X(s/R)

    Bar is to low at iPhone X(s/R)

    At the Bottom of the iPhone X... is the Navigation "Line". At this point there should be white space. The Navy Bar is behind this Line.

    image

    How it should look:

    image

    bug 
    opened by kay4ik 4
  • maximize the touch area

    maximize the touch area

    Hi, thank you for this amazing package, I feel very helped by this, but I think the touch area is very small, it's very difficult to always press right on the icon, so I maximize the touch area to make it easier to use.

    sorry if my English is difficult to understand, I use Google translate.

    • before

    before01 before02

    • after after01 aftar02
    opened by Sayutizxc 3
  • Don't use specific widgets

    Don't use specific widgets

    BottomNavyBar forces us to pass an Icon and a Text. If those properties are of type Widget, then we can pass a lot more usefull things, like SVG icons with badges, etc.

    I did this change and it should work without any breaking changes:

    class BottomNavyBarItem {
      final Widge icon; // <--- Widget instead of Icon
      final Widget title; // <--- Widget instead of Text
      final Color activeColor;
      final Color inactiveColor;
      final TextAlign textAlign;
    
      BottomNavyBarItem({
        @required this.icon,
        @required this.title,
        this.activeColor = Colors.blue,
        this.textAlign,
        this.inactiveColor,
      }) {
        assert(icon != null);
        assert(title != null);
      }
    }
    
    enhancement 
    opened by JCKodel 3
  • Error selectedIndex

    Error selectedIndex

    BottomNavyBar(
       selectedIndex: _selectedIndex,
       showElevation: true, // use this to remove appBar's elevation
       onItemSelected: (index) => setState(() {
                  _selectedIndex = index;
                  _pageController.animateToPage(index,
                      duration: Duration(milliseconds: 300), curve: Curves.ease);
        }),
    

    BottomNavyBar has a currentIndex not selectedIndex. bottom_navy_bar: ^3.0.0 Flutter 1.7.8

    opened by malikdoksoz 3
  • Can't set default active item before Tap

    Can't set default active item before Tap

    I'd like to have an item(Tab) to be selected on the first launch, but it only reacts to a tap. index is 0 by default, but it awaits for a tap, all tabs have inactive view by default.

    good first issue 
    opened by Shakle 3
  • Disable Swiping Right or Left

    Disable Swiping Right or Left

    Hello. Is it possible to disable Swiping Right or Left? I only want to switch between screens by clicking on the bottom navy bar icons, Not Swiping pages right or left

    I really appreciate your work, Nice bottom_navy_bar πŸ‘

    invalid question 
    opened by Mohdx 2
  • Work with Routes

    Work with Routes

    Hi, this works fine with PageView on an app with a single StatefulWidget , but on a more complex app with multiple Stateful/Stateless classes connected using Navigator and each having a bottom navigation bar, the animation does not fire.

    class MyHomePage extends StatefulWidget {
      MyHomePage({Key key}) : super(key: key);
    
      @override
      _MyHomePageState createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      int currentIndex = 0;
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text('MyPage'),
          ),
          body: Center(child: Text('MyPage')),
          bottomNavigationBar: BottomNavyBar(
            selectedIndex: currentIndex,
            showElevation: true,
            itemCornerRadius: 8,
            curve: Curves.easeInBack,
            onItemSelected: (index) => setState(() {
              Navigator.push(context,
                  MaterialPageRoute(builder: (BuildContext context) => Page2()));
            }),
            items: [
              BottomNavyBarItem(
                icon: Icon(Icons.apps),
                title: Text('MyPage'),
                activeColor: Colors.red,
                textAlign: TextAlign.center,
              ),
              BottomNavyBarItem(
                icon: Icon(Icons.people),
                title: Text('Page2'),
                activeColor: Colors.purpleAccent,
                textAlign: TextAlign.center,
              ),
            ],
          ),
        );
      }
    }
    
    class Page2 extends StatefulWidget {
      @override
      _Page2State createState() => _Page2State();
    }
    
    class _Page2State extends State<Page2> {
      int currentIndex = 1;
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          bottomNavigationBar: BottomNavyBar(
            selectedIndex: currentIndex,
            showElevation: true,
            itemCornerRadius: 8,
            curve: Curves.easeInBack,
            onItemSelected: (index) => setState(() {
              Navigator.push(
                  context,
                  MaterialPageRoute(
                      builder: (BuildContext context) => MyHomePage()));
            }),
            items: [
              BottomNavyBarItem(
                icon: Icon(Icons.apps),
                title: Text('MyPage'),
                activeColor: Colors.red,
                textAlign: TextAlign.center,
              ),
              BottomNavyBarItem(
                icon: Icon(Icons.people),
                title: Text('Page2'),
                activeColor: Colors.purpleAccent,
                textAlign: TextAlign.center,
              ),
            ],
          ),
          body: Center(
            child: Text('Page2'),
          ),
        );
      }
    }
    
    opened by RodBr 2
  • ImageIcon

    ImageIcon

    Hello, as my icons are customized I can only access using icon: ImageIcon(images/ icon.png), in BottomNavigationBarItem I can, but in your package only accept Icon in icon (icon: Icon(Icons.add) How to solve?

    enhancement 
    opened by fabioselau077 2
  • Make corner radius configurable on each BottomNavyBarItem

    Make corner radius configurable on each BottomNavyBarItem

    Will default to 50 for radius as per the current code. But it can now be configured on a BottomNavyBarItem by BottomNavyBarItem case, this allows for squares with rounded corners rather than just having to have the pill style.

    I have forked and run this code in my project (see below)

    image

    opened by georgeherby 2
  • feat: add customization options

    feat: add customization options

    This is the re-implementation of most of the work done on #67 - however with a little bit missing and some optimization to the options.

    Let's see if this one can ever be merged. πŸ‘

    opened by Xazin 0
  • Bottom_navy_bar does not support null-saftey well

    Bottom_navy_bar does not support null-saftey well

    Although it is from Flutter's favorites list but it is not well supported, as the last modification was 13 months ago. I used it in a project but I had to modify it to accept null-safety . Please Flutter team support your packages.

    opened by RasheedSanad 0
  • Bottom overflow by

    Bottom overflow by "X' pixel

    This is the same issue reported on #59.

    On small devices, having 5 items can overflow because the width of every single item is fixed when you are building them: 130 for the selected one and 50 otherwise. I've tested on a Nexus 5S that has 320 pixels wide and with 5 items without considering padding it requires 330 logical pixels.

    My suggestion would be to calculate twice the space for the selected one and divide the remaining space to the other items and pass this constraints to the item being built. Something like this:

    final screenSize = MediaQuery.of(context).size;
    
        const itemSidePadding = 12;
    
        final maxItemWidth =
            screenSize.width * (1 / items.length) - (itemSidePadding * 2);
        final maxSelectedWidth =
            screenSize.width * (2 / (items.length)) - (itemSidePadding * 2);
    

    Sorry if I did something wrong here, this is my first ever issue report on git.

    Love your work, thank you for this amazing package!

    opened by OAndreLuizSilva 1
  • Letters hidden if the word is too long

    Letters hidden if the word is too long

    Hi,

    i'm trying to use this package and i have a BottomNavyBarItem with a title maybe too long. The title is "notifications", seems like it gets cutted on iPhone 11 pro.

    Is there any solution to this?

    Thank you!

    Schermata 2021-09-07 alle 01 33 02
    opened by agostinofiscale 2
  • Added showSelectionShape and cursor, as options to set the Bottom Navy Bar

    Added showSelectionShape and cursor, as options to set the Bottom Navy Bar

    Hi, Pedro πŸ‘‹πŸ»

    I added two new properties to the Bottom Navy Bar Widget:

    • showSelectionShape: Defaults to true. Its function is to give the option to disable the highlight color shape.
    • cursor: Defaults to clickable cursor. Its function is to change the cursor of the items hover. This is mainly for the web hover.

    Please, check the changes, and tell me what do you think. I hope my contribution will be useful.

    Regards, Alejandro Ramos...

    πŸ’™

    opened by arhcoder 0
Releases(6.0.0)
Owner
Pedro Massango
Self-taught (mobile) developer. Not quite good at it yet but I'm keep learning :)
Pedro Massango
A beautiful and simple bottom navigation bar with smooth animation when switching selected item.

Titled Bottom Navigation Bar A beautiful, clean and simple bottom navigation bar with smooth animation on click. This package is high customizable, re

Pedro Massango 327 Dec 26, 2022
A beautiful and animated bottom navigation

BottomNavyBar A beautiful and animated bottom navigation. The navigation bar use your current theme, but you are free to customize it. Preview PageVie

Pedro Massango 870 Dec 30, 2022
Flutter-nav-bottom-bar-tutorial - A flutter bottom navigation bar tutorial

Flutter Bottom Navigation Bar Tutorial A tutorial with various Flutter bottom na

Aleyna Eser 2 Oct 25, 2022
A fancy animated bottom navigation bar πŸ’«.

Stacky_bottom_nav_bar A fancy animated bottom navigation bar. Preview Default Light Mode Default Dark Mode ⚠️ IMPORTANT: when adding this widget don’t

null 5 Oct 23, 2022
A beautiful and simple bottom navigation bar with smooth animation when switching selected item.

Titled Bottom Navigation Bar A beautiful, clean and simple bottom navigation bar with smooth animation on click. This package is high customizable, re

Pedro Massango 327 Dec 26, 2022
Flutter Navigation Best Practices including adapting navigation to platform and branding techniques for navigation surfaces.

Flutter Navigation Best Practices including adapting navigation to platform and branding techniques for navigation surfaces.

Fred Grott 5 Aug 22, 2022
Custom bottom bar - A bottom tool bar that can be swiped left or right to expose more tools.

custom_bottom_bar A bottom tool bar that can be swiped left or right to expose more tools. usage Create your custom bottom bars with up to four custom

null 4 Jan 26, 2020
Doctor Consultation App in Flutter containing splash screen on boarding screen Routing state management Dash board Bottom navigation Decorated Drawer and Doctors Screen in the last.

Online doctor Consultation App UI in Flutter Doctor Consultation App UI in Flutter Visit Website Features State Management Navigation Bar Responsive D

Habib ullah 14 Jan 1, 2023
Playful and customizable bottom navigation bar for Flutter

rolling_nav_bar A bottom nav bar with layout inspired by this design and with heavily customizable animations, colors, and shapes. Getting Started To

Craig Labenz 117 Dec 22, 2022
flutter bottom navigation bat project

bottom_navigation A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you starte

Danushan Ravendran 3 Sep 23, 2021
Custom Bottom navigation bar on Flutter.

Intro Custom Bottom navigation bar on Flutter. The updated one Support : Null safety & Support 9 items on Tabs & Some Color, Size, Effects and font cu

Ihab Zaidi 2 Oct 8, 2021
How to add a notification badge in bottom navigation bar

bottom_navigation_badge / BottomNavigationBadge BottomNavigationBadge is a Flutter class developed by westdabestdb. Getting Started Add this to your p

GΓΆrkem Erol 50 May 21, 2022
Bottom navigation bar with sliding clip effect.

Sliding Clipped Nav Bar Design Credit Toolbar icons animation by Cuberto How to use? API reference barItems β†’ List<BarItem> List of bar items that sho

Watery Desert 55 Dec 3, 2022
Custom bottom navigation bar with diamond icon in the middle.

Pub.dev Scaled List Custom bottom navigation bar with diamond icon in the middle you can customize the number of items either be Five or three. Usage

Hosain Mohamed 4 Dec 21, 2022
A custom bottom navigation bar with box animation for flutter

A custom bottom navigation bar with box animation. This is inspired from some of the earlier designs, but in a more simplified and yet exiting way. De

SHIVAM SONI 1 Jul 31, 2022
New trick on how to create your own custom icons in flutter with bottom bar navigation

Customized Bottom Navigation Bar in Flutter | Tech With Sam Customized Bottom Navigation Bar in Flutter - Watch on youtube ✌   App Preview App Screens

Samuel Adekunle 10 Oct 26, 2022
This is repository for Spin Circle Bottom Navigation Bar Package for Flutter

Spin Circle Bottom Bar An easy to implement Spin Circle Bottom Navigation Bar for Flutter Applications. Current Features Initial Release for Spin Circ

Paras Jain 79 Dec 22, 2022
simple flutter bottom navigation bar widget

bmnav A very flexible Flutter implementation of the Bottom Navigation Bar. Get Started Add bmanv to your pubspec.yaml file: dependencies: bmnav: ^0.

Edwin 21 Oct 8, 2022
A 3D Bottom Navigation Bar in Flutter

flip_box_bar A 3D BottomNavigationBar inspired by Dribbble design by Dannniel [https://dribbble.com/shots/4811135-Tab-Bar-Cube-Interaction]. Demo Exam

Deven Joshi 258 Nov 19, 2022
Customized πŸš€ Bottom Navigation Bar Using Flutter 🐦

Customized ?? Bottom Navigation Bar Using Flutter ??

AmirHossein Bayat 3 Dec 7, 2022