简体   繁体   English

如何使 Flutter BottomNavigationBarItem 图标和 label 在同一行

[英]How to make Flutter BottomNavigationBarItem icon and label in same line

I am trying to make a bottomnavigation bar in flutter.我正在尝试在 flutter 中制作一个底部导航栏。 I have used the following code to make a bottom navigation bar.我使用以下代码制作了底部导航栏。

child: BottomNavigationBar(
        currentIndex: 0,
        backgroundColor: Colors.red.withOpacity(0),
        type: BottomNavigationBarType.fixed,
        // showSelectedLabels: false,
        showUnselectedLabels: false,
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Icon(
              Icons.circle,
              color: Colors.white,
              size: 8,
            ),
            label: 'Explore',
            backgroundColor: Colors.red,
          ),
          BottomNavigationBarItem(
            icon: Icon(
              Icons.shop,
              color: Colors.white,
              size: 17,
            ),
            label: '',
            backgroundColor: Colors.red,
          ),
          BottomNavigationBarItem(
            icon: Icon(
              Icons.favorite,
              color: Colors.white,
              size: 17,
            ),
            label: '',
          ),
          BottomNavigationBarItem(
            icon: Icon(
              Icons.person,
              color: Colors.white,
              size: 17,
            ),
            label: '',
          ),
        ],
        selectedItemColor: Colors.white,
        // onTap:
      ),

It looks like this:它看起来像这样: 在此处输入图像描述

I want that my first bottomnavigationbaritem ie '.'我想要我的第一个底部导航条,即“。” and 'explore' to be on same line.和“探索”在同一行。 I tried using Container and other widget but it didnot worked.我尝试使用 Container 和其他小部件,但没有奏效。

You should create a Custom Bottmnavigation Bar .您应该创建一个自定义 Bottmnavigation Bar for example:例如:

Scaffold {
bottomNavigationBar: Container (
                       height: 60,
                       decoration: BoxDecoration(
                                     color: Theme.of(context).primaryColor,
                                     borderRadius: const BorderRadius.only(
                                     topLeft: Radius.circular(20),
                                     topRight: Radius.circular(20),
                      ),
                      child : Row(
                           children: [
                           Row(
                              children : [
                                       Icon(
                                          Icons.circle,
                                          color: Colors.white,
                                          size: 8,
                                           ),
                                           Text('Explore')
                                         ]
                                    ),
                                   Row(
                              children : [
                                       Icon(
                                          Icons.circle,
                                          color: Colors.white,
                                          size: 8,
                                           ),
                                           Text('Explore')
                                         ]
                                    ),
                                   Row(
                              children : [
                                       Icon(
                                          Icons.circle,
                                          color: Colors.white,
                                          size: 8,
                                           ),
                                           Text('Explore')
                                         ]
                                    ),
                                  ]
                                ) 
                             ),
                           ) 
                }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Flutter 中为 BottomNavigationBarItem 添加徽章? - How to add badge to BottomNavigationBarItem in Flutter? BottomNavigationBarItem label 在 flutter 中选择时不显示 - BottomNavigationBarItem label not showing when selected in flutter 如何在flutter中将徽章计数数字添加为BottomNavigationBarItem的一部分 - How to add a badge count number as part of a BottomNavigationBarItem in flutter 当用户点击 BottomNavigationBarItem 时如何显示 flutter modalBottomSheet - How to display a flutter modalBottomSheet when user taps a BottomNavigationBarItem 如何制作BottomNavigationView水平方向的图标和标签? - How to make BottomNavigationView Horizontally Oriented Icon and Label? 单击图标时 BottomNavigationBarItem 打开相应的页面 - BottomNavigationBarItem open respective page when clicked on the Icon 如何使Android中的图标与文字大小相同? - How to make icon the same size as text in Android? Flutter - TextFormfield 在 UI 中占用太多填充/额外空间/如何使 label 文本在活动/非活动时具有相同大小 - Flutter - TextFormfield is taking too much padding/extra space in UI/How to make label text the same size when it is active/inactive 如何在颤动的BottomAppBar中的图标正下方制作文本? - How to make a text right below an icon in BottomAppBar in flutter? 如何在我的 flutter 应用程序中使汉堡图标更大 - how can i make the burger icon bigger in my flutter app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM