[英]How to change unselected tabs background color in `TabBar` in flutter?
Folowing is my code:以下是我的代码:
TabBar(
// isScrollable: true,
unselectedLabelColor: Colors.grey,
labelColor: Colors.black,
// labelColor: Colors.white,
// indicatorSize: TabBarIndicatorSize.tab,
indicator: BoxDecoration(
borderRadius: BorderRadius.circular(50),
color: Colors.white),
tabs: tabs,
controller: _tabController,
)
I am trying to change the background colour of unselected tabs like in my mock我正在尝试更改未选择选项卡的背景颜色,就像在我的模拟中一样
TabController _tabController;
@override
void initState() {
super.initState();
_tabController = new TabController(vsync: this, length: 2);
_tabController.addListener(_handleTabSelection);
}
void _handleTabSelection() {
setState(() {
});
}
TabBar(
controller: _tabController,
indicatorColor: Colors.grey,
labelColor: Colors.black,
unselectedLabelColor: Colors.grey,
tabs: [
Tab(
text: 'First',
icon: Icon(Icons.home,
color: _tabController.index == 0
? Colors.black
: Colors.grey)),
Tab(
text: 'Second',
icon: Icon(Icons.person,
color: _tabController.index == 1
? Colors.black
: Colors.grey)),
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.