Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I add spacing around an icon in Flutter Bottom Navigation Bar?

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;
                  });
                },
              ),
like image 203
Apps 247 Avatar asked Feb 10 '20 13:02

Apps 247


People also ask

How do you customize the bottom navigation bar in flutter?

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.

How do you navigate the bottom navigation bar in flutter?

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.

How do you change the text size in bottom navigation in flutter?

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.


1 Answers

My usage of @Ludovic Garon answer

icon: Padding( padding: EdgeInsets.all(16.0), child: Icon(Icons.search), ),

like image 198
Giedrius Šlikas Avatar answered Oct 11 '22 03:10

Giedrius Šlikas