【问题标题】:The Label Color doesn't change on the BottomNavigationBarBottomNavigationBar 上的标签颜色不会改变
【发布时间】:2021-05-29 16:25:59
【问题描述】:

我选择和未选择的 BottomNavigationBarItems 标签的颜色没有改变......我做错了什么?代码如下:

bottomNavigationBar: BottomNavigationBar(
        selectedLabelStyle: TextStyle(color: Colors.black),
        unselectedLabelStyle: TextStyle(color: Colors.black),
        backgroundColor: Colors.white,
        
        onTap: onTabTapped,
        currentIndex: _currentIndex, // this will be set when a new tab is tapped
        items: [
          BottomNavigationBarItem(
            icon: Icon(Icons.home, color: Colors.black,),
            label: 'Home',

          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.search, color: Colors.black,),
            label: 'Messages',
          ),
          BottomNavigationBarItem(
              icon: Icon(Icons.person, color: Colors.black,),
              label: 'Profile'
          )
        ],
      ),

【问题讨论】:

    标签: flutter dart flutter-bottomnavigation textstyle


    【解决方案1】:

    您可以使用子属性并添加可以轻松设置文本样式的文本类

    【讨论】:

      【解决方案2】:

      改变这个

      selectedLabelStyle: TextStyle(color: Colors.black),
      unselectedLabelStyle: TextStyle(color: Colors.black),
      

      到这里:

      selectedItemColor: Colors.black,
      unselectedItemColor: Colors.black,
      

      【讨论】:

        猜你喜欢
        • 2017-07-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-12-06
        • 1970-01-01
        • 2016-09-11
        • 2019-05-24
        相关资源
        最近更新 更多