如何更改 bottomNavigationBar 的颜色?

sud*_*rah 4 flutter

如何更改 a 的颜色bottomNavigationBar

下面是我的代码片段。我无法更改小部件的颜色。

@override
  Widget build(BuildContext context) {
    return BottomNavigationBar(

      currentIndex: currentIndex,
      onTap: (selectedPosition) => onNavItemTapped(selectedPosition),
      items: <BottomNavigationBarItem>[
        widget.buildBottomNavigationBarItem(
            context, 'Discover', Icons.home, false, 0),
        widget.buildBottomNavigationBarItem(
            context, 'Chats', Icons.chat, true, 1),
      ],
    );
  }
Run Code Online (Sandbox Code Playgroud)

MUH*_* PA 5

请像这样使用:

bottomNavigationBar: new Theme(
        data: Theme.of(context).copyWith(
          // sets the background color of the `BottomNavigationBar`
          canvasColor: Colors.red,
        ),
        child: BottomNavigationBar(
          type: BottomNavigationBarType.fixed,
          ..........
Run Code Online (Sandbox Code Playgroud)