没有其他选项可以指定的背景色,
BottomNavigationBar而只能更改
canvasColor。在不弄乱整个应用程序的情况下实现此目标的一种方法是将包裹
BottomNavigationBar在
Theme所需的中
canvasColor。
例:
bottomNavigationBar: new Theme( data: Theme.of(context).copyWith( // sets the background color of the `BottomNavigationBar` canvasColor: Colors.green, // sets the active color of the `BottomNavigationBar` if `Brightness` is light primaryColor: Colors.red, textTheme: Theme .of(context) .textTheme .copyWith(caption: new TextStyle(color: Colors.yellow))), // sets the inactive color of the `BottomNavigationBar` child: new BottomNavigationBar( type: BottomNavigationBarType.fixed, currentIndex: 0, items: [ new BottomNavigationBarItem( icon: new Icon(Icons.add), title: new Text("Add"), ), new BottomNavigationBarItem( icon: new Icon(Icons.delete), title: new Text("Delete"), ) ], ), ),希望有帮助!



