【问题标题】:Why am I not able to change the background color of my bottom navigation bar in Flutter?为什么我无法在 Flutter 中更改底部导航栏的背景颜色?
【发布时间】:2023-01-04 17:16:05
【问题描述】:

我想将底部导航栏的背景颜色更改为黑色,但它仍然是白色。是什么导致了这个问题? [![底部导航的屏幕截图][1]][1]

底部导航栏截图 [1]:https://i.stack.imgur.com/KXyKp.png

底部导航条码。

bottomNavigationBar: BottomNavigationBar(
    onTap: _onItemTapped,
    type: BottomNavigationBarType.shifting,
    iconSize: 30,

    unselectedItemColor: Colors.black,
    selectedIconTheme: const IconThemeData(color: Colors.black, size: 30),
    selectedItemColor: Colors.black,
    selectedLabelStyle: const TextStyle(fontWeight: FontWeight.bold),
    backgroundColor: Colors.white,

    items: const <BottomNavigationBarItem>[
      BottomNavigationBarItem(
        icon: Icon(Icons.home),
        label: 'Home',
      ),
      BottomNavigationBarItem(
        icon: Icon(Icons.door_back_door),
        label: 'Rooms',
      ),
      BottomNavigationBarItem(
        icon: Icon(Icons.search),
        label: 'Search',
      ),
      BottomNavigationBarItem(
        icon: Icon(Icons.map),
        label: 'Maps',
      ),
      BottomNavigationBarItem(
        icon: Icon(Icons.person),
        label: 'Profile',
      ),
    ],
    currentIndex: _selectedIndex,
  ),

我一直在努力弄清楚这部分,但我似乎看不出问题的原因。如果可能的话,我将不胜感激! :)

【问题讨论】:

  • 你试过设置backgroundColor: Colors.black吗?

标签: flutter dart


【解决方案1】:

您可以通过编辑 backgroundColor 属性来更改颜色:-

backgroundColor: Colors.black,

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多