更改 BottomNavigationBar 的背景颜色?

Change BackGround Color of BottomNavigationBar?

我正在使用 Flutter 的 Nested Navigators 插件 https://pub.dev/packages/nested_navigators

我相信我应该能够使用 backgroundColor 作为参数来更改 BottomNavigationBar 的背景颜色;

buildBottomNavigationItem: (key, item, selected) =>
          BottomNavigationBarItem(
            icon: Icon(
              item.icon,
              color: Colors.blue,
            ),
            title: Text(
              item.text,
              style: TextStyle(fontSize: 14),
            ),
          ),
     bottomNavigationBarTheme: Theme.of(context).copyWith(
       splashColor: Colors.blue[200],
       primaryColor: Colors.green[300],
       backgroundColor: Colors.orange,
      ),

但是,遗憾的是,BottomNavigationBar 固执地拒绝使用白色以外的任何颜色。知道出了什么问题吗?

解决方案是将 build BottomNavigationItem 替换为

buildCustomBottomNavigationItem: (key, item, selected) => Container(
         color: Color(0xffb79eb5).withOpacity(.70),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Icon(
                item.icon,
                size: 18,
                color: selected ? Colors.white : Colors.black38,
              ),
              Text(
                item.text,
                style: TextStyle(fontSize: 16, color: selected ? Colors.white : Colors.black38),
              ),
            ],
          ),
        ),