I want to define unselected color of icon in tab just like unselectedLabelColor.
TabBar(
indicatorColor: Colors.grey,
labelColor: Colors.black,
unselectedLabelColor: Colors.grey,
tabs: [
Tab(
text: 'first',
icon: Icon(Icons.directions_car, color: Colors.grey)),
Tab(
text: 'second',
icon: Icon(Icons.directions_transit, color: Colors.grey)),
Tab(
text: 'third',
icon: Icon(Icons.directions_bike, color: Colors.grey)),
],
)
Try to set appBar border : appBar: AppBar( shape: Border(bottom: BorderSide(color: Colors. red)), .... what you suggested is too close, it's only under the indicatorColor.
As per the directions given by Britannio, I have solved my problem but I want to share my solution so that it can help others. I am confused about one thing that I have to call setState() with empty body which is not recommended so if any one have a better solution then please comment. I'll update it.
TabController _tabController;
@override
void initState() {
super.initState();
_tabController = new TabController(vsync: this, length: 3);
_tabController.addListener(_handleTabSelection);
}
void _handleTabSelection() {
setState(() {
});
}
TabBar(
controller: _tabController,
indicatorColor: Colors.grey,
labelColor: Colors.black,
unselectedLabelColor: Colors.grey,
tabs: [
Tab(
text: 'Sale',
icon: Icon(Icons.directions_car,
color: _tabController.index == 0
? Colors.black
: Colors.grey)),
Tab(
text: 'Latest',
icon: Icon(Icons.directions_transit,
color: _tabController.index == 1
? Colors.black
: Colors.grey)),
Tab(
text: 'Popular',
icon: Icon(Icons.directions_bike,
color: _tabController.index == 2
? Colors.black
: Colors.grey)),
],
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With