I have a Bottom Navigation Bar in Flutter, and plan on using Font Awesome Icons for the items. However, when compared to material icons, font awesome icons don't have any spacing around them. This makes them touch the Bottom Navigation Bar Item titles. Is there any way i can add space between these?
Bottom Navigation Bar Code:
BottomNavigationBar(
type: BottomNavigationBarType.shifting,
currentIndex: _currentIndex,
items: [
BottomNavigationBarItem(
icon: Icon(
Icons.list,
size: 30.0,
),
title: Text('Notice Board'),
backgroundColor: Colors.grey[900],
),
BottomNavigationBarItem(
icon: Icon(
FontAwesomeIcons.handsHelping,
// size: 30.0,
),
title: Text('Services'),
backgroundColor: Colors.green,
),
BottomNavigationBarItem(
icon: Icon(
Icons.add,
size: 35.0,
),
title: Text('Create'),
backgroundColor: Colors.cyan,
),
BottomNavigationBarItem(
icon: Icon(
FontAwesomeIcons.store,
// size: 30.0,
),
title: Text('Marketplace'),
backgroundColor: Colors.orange,
),
],
onTap: (index) {
setState(() {
_currentIndex = index;
});
},
),
Now let's create our bottom navigation bar. In the HomePage class let's define the bottomNavigationBar attribute and assign a Container to it. Give it a height of 60 with some BoxDecoration (Pixels) add a Row as the child of the Container. Set the main axis alignment to space around.
BottomNavigationBar is a widget that displays a row of small widgets at the bottom of a Flutter app. Usually, it's used to show around three to five items. Each item must have a label and an icon. BottomNavigationBar allows you to select one item at a time and quickly navigate to a given page.
There is a property selectedFontSize on the BottomNavigationBar . You can use this one. Simply set the size (interger) to the desired value. Additionaly; there is also a unselectedFontSize on the BottomNavigationBar , ther you can set all the title-fontsize attonce to the desired size.
My usage of @Ludovic Garon answer
icon: Padding(
padding: EdgeInsets.all(16.0),
child: Icon(Icons.search),
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With