I have 3 button in a row like these :
button 1 button 2 button 3
and I want just the text of selected one bolded.
for example :
button 1 button 2 button 3
what's the best and easiest way?
CodePudding user response:
Create a variable to hold the current button thats selected. Then based on that you can switch the fontWeight like the following
int selectedButton = 0;
Row(
children:List.generate(3, (index) {
return InkWell(
onTap:(){
setState((){selectedButton = index;});
},
child: Text("button $index", style: TextStyle(
fontWeight : selectedIndex == index ? FontWeight.w900: FontWeight.w400,
))
)
})
)