首页 > 解决方案 > 如何更改底部导航栏颤动的颜色?

问题描述

我想在选择时更改底部导航栏中的颜色。每个图标都有不同的颜色。我怎么做?

这是代码:

          bottomNavigationBar: new TabBar(
            tabs: [
              Tab(
                icon: new Icon(Icons.home),             
              ),
              Tab(
                icon: new Icon(Icons.search),
              ),
              Tab(
                icon: new Icon(Icons.account_box),
              ),
              Tab(
                icon: new Icon(Icons.enhanced_encryption),
              ),
              Tab(icon: new Icon(Icons.store),)
            ],
            labelColor: Colors.black,
            unselectedLabelColor: Colors.grey[500 ],
            indicatorSize: TabBarIndicatorSize.tab,
            indicatorPadding: EdgeInsets.all(5),
            indicatorColor: Colors.red,


          ),
          backgroundColor: Colors.white,
        ),
      ),
    );
  }
}

先感谢您

标签: flutterdartflutter-layout

解决方案


One way to do this would be to create a boolean list that represents the tabs, when selecting a tab changes the boolean value for it, and in icon color use a binary to display the color!

Icon (
  Icons.home,
  color: checkSelected[0] ? Colors.yellow : Colors.grey,
),

希望这可以帮助!


推荐阅读