Let's suppose that I have 3 button( OutlinedButton, in my case).
What I want to make is to toggle the color of outlines of all buttons, not individually.
For example If I press button 1, the outline color of button 1 goes yellow, and the color of outlines of button 2 and 3 goes white.
What I tried is this :
List<dynamic> colorlist_down = [Colors.amber,Colors.white,Colors.white];
...
return Row(
children:
[
OutlinedButton(
onPressed: (){
setState(() {
mode=0;
colorlist_down = [Colors.amber,Colors.white,Colors.white];
});
},
style: OutlinedButton.styleFrom(
primary: colorlist_down.elementAt(0),
side: BorderSide(color: colorlist_down.elementAt(0), width: 2),
),
child: Text('Filter : Age',style: TextStyle(color: Colors.brown[900]))
),
OutlinedButton(
onPressed: (){
setState(() {
mode=1;
colorlist_down = [Colors.white,Colors.amber,Colors.white];
});
},
style: OutlinedButton.styleFrom(
primary: colorlist_down.elementAt(1),
side: BorderSide(color: colorlist_down.elementAt(1), width: 2),
),
child: Text('Filter : Gender',style: TextStyle(color: Colors.brown[900]))
),
OutlinedButton(
onPressed: (){
setState(() {
mode=2;
colorlist_down = [Colors.white,Colors.white,Colors.amber];
});
},
style: OutlinedButton.styleFrom(
primary: colorlist_down.elementAt(2),
side: BorderSide(color: colorlist_down.elementAt(2), width: 2),
),
child: Text('Filter : Location',style: TextStyle(color: Colors.brown[900]))
),
]
);
Of course it did not work.
I think that the style of buttons do not react to state change and somehow found that I should use MaterialStateProperty, but cannot get how to use it correctly for my purpose. Somebody please give me a help .