[英]How do I add background color to unselected tabs in flutter tabbar?
[英]How to change unselected tabs background color in `TabBar` in flutter?
以下是我的代碼:
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,
)
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.