This is i want to setwhen tab is select or I want to try when the user select a tab from the tab bar at that time i want to change selected tab cion background color.
Tab( text: StringConstant.cricketTitle, icon: Icon(Icons.sports_cricket_outlined,color: Colors.white,),),
const TabBar( dividerHeight: 0, padding: EdgeInsets.zero, indicatorColor: Colors.white, indicatorPadding: EdgeInsets.zero, labelPadding: EdgeInsets.zero, automaticIndicatorColorAdjustment: false, unselectedLabelStyle:const TextStyle(color: white40,),
tabs: [
Tab(
text: StringConstant.cricketTitle,
icon: Icon(Icons
.sports_cricket_outlined,) /*ImageIcon(AssetImage(ImagePathConstant.cricketImage))*/,
),
Tab(
text: StringConstant.footBallTitle,
icon: Icon(Icons
.sports_soccer) /*ImageIcon(AssetImage(ImagePathConstant.footBallImage))*/,
),
Tab(
text: StringConstant.kabaddiTitle,
icon: Icon(Icons
.sports_kabaddi_outlined) /*ImageIcon(AssetImage(ImagePathConstant.kabbadiImage))*/,
),
Tab(
text: StringConstant.basketBallTitle,
icon: Icon(Icons
.sports_basketball_outlined) /* ImageIcon(AssetImage(ImagePathConstant.basketBallImage))*/,
),
Tab(
text: StringConstant.volleyBallTitle,
icon: Icon(Icons
.sports_volleyball_outlined) /* ImageIcon(AssetImage(ImagePathConstant.volleyBallImage))*/,
),
])
int _selectedIndex = 0;
In TabBar take onTap method as
onTap: (value) {
setState(() {
_selectedIndex = value;
});
},
And check tab icon color like below
Icon(Icons.home, color: _selectedIndex == 0 ? Colors.white : Colors.black)