bottom_nav_bar 1.0.1
bottom_nav_bar: ^1.0.1 copied to clipboard
An easy-to-use and clean bottom navigation bar.
BottomNavBar #
An easy-to-use and clean bottom navigation bar.
Preview 1 | Preview 1 | Preview 1 |
---|---|---|
![]() |
![]() |
![]() |
Available Customization options #
BottomNavBar #
iconSize
- the item icon's sizeitems
- navigation items, item length should be from 3 to 5selectedIndex
- the current item index. Use this to change the selected item. Defaults to zeroonItemSelected
- required to listen when an item is tapped it provides the selected item's indexbackgroundColor
- the navigation bar's background colorshowElevation
- if false the appBar's elevation will be removedmainAxisAlignment
- 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 itemscurve
- param to customize the item change's animationcontainerHeight
- changes the Navigation Bar's heightcontainerPadding
- changes the Navigation Bar's padding
BottomNavBarItem #
icon
- the icon of this itemtitle
- the text that will appear next to the icon when this item is selectedactiveColor
- the active item's icon and text colorinactiveColor
- the inactive item's icon coloractiveBackgroundColor
- the active item's background colorinactiveBackgroundColor
- the inactive item's background color
Getting Started #
Add the dependency in pubspec.yaml
:
dependencies:
...
bottom_nav_bar: ^1.0.0
Basic Widget #
bottomNavigationBar: BottomNavBar(
showElevation: true,
selectedIndex: _currentIndex,
onItemSelected: (index) {
setState(() => _currentIndex = index);
},
items: <BottomNavBarItem>[
BottomNavBarItem(
title: 'Home',
icon: const Icon(Icons.home),
activeColor: Colors.white,
inactiveColor: Colors.black,
activeBackgroundColor: Colors.red.shade300,
),
BottomNavBarItem(
title: 'Profile',
icon: const Icon(Icons.person),
activeColor: Colors.white,
inactiveColor: Colors.black,
activeBackgroundColor: Colors.blue.shade300,
),
BottomNavBarItem(
title: 'Message',
icon: const Icon(Icons.chat_bubble),
inactiveColor: Colors.black,
activeColor: Colors.white,
activeBackgroundColor: Colors.green.shade300,
),
BottomNavBarItem(
title: 'Settings',
icon: const Icon(Icons.settings),
inactiveColor: Colors.black,
activeColor: Colors.black,
activeBackgroundColor: Colors.yellow.shade300,
),
],
)
Full Example using IndexedStack #
class RootPage extends StatefulWidget {
const RootPage({Key? key}) : super(key: key);
@override
_RootPageState createState() => _RootPageState();
}
class _RootPageState extends State<RootPage> {
int _currentIndex = 0;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: _body(),
bottomNavigationBar: _bottomNavBar(),
);
}
Widget _body() => SizedBox.expand(
child: IndexedStack(
index: _currentIndex,
children: const <Widget>[
PageOne(),
PageTwo(),
PageThree(),
PageFour(),
],
),
);
Widget _bottomNavBar() => BottomNavBar(
showElevation: true,
selectedIndex: _currentIndex,
onItemSelected: (index) {
setState(() => _currentIndex = index);
},
items: <BottomNavBarItem>[
BottomNavBarItem(
title: 'Home',
icon: const Icon(Icons.home),
activeColor: Colors.white,
inactiveColor: Colors.black,
activeBackgroundColor: Colors.red.shade300,
),
BottomNavBarItem(
title: 'Profile',
icon: const Icon(Icons.person),
activeColor: Colors.white,
inactiveColor: Colors.black,
activeBackgroundColor: Colors.blue.shade300,
),
BottomNavBarItem(
title: 'Message',
icon: const Icon(Icons.chat_bubble),
inactiveColor: Colors.black,
activeColor: Colors.white,
activeBackgroundColor: Colors.green.shade300,
),
BottomNavBarItem(
title: 'Settings',
icon: const Icon(Icons.settings),
inactiveColor: Colors.black,
activeColor: Colors.black,
activeBackgroundColor: Colors.yellow.shade300,
),
],
);
}