0

我选择和未选择的 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'
          )
        ],
      ),
4

2 回答 2

0

改变这个

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

对此:

selectedItemColor: Colors.black,
unselectedItemColor: Colors.black,
于 2021-05-29T16:36:21.527 回答
0

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

于 2021-05-29T16:30:09.297 回答