'Flutter - how to change radio background color
Flutter Radio background is transparent by default, is it possible to change it?
I can wrap with container and set background container color. However, the radio has a padding for hover color, so there is a padding between container background and radio button. I can hardcode container size but it is not good solution.
Container(
width: 20,
height: 20,
decoration: BoxDecoration(color: Colors.orange, shape: BoxShape.circle),
child: Theme(
data: Theme.of(context).copyWith(
unselectedWidgetColor: Colors.white
),
child: Radio(
value: gender,
activeColor: Colors.white,
groupValue: _gender,
onChanged: (Gender value) {
setState(() {
_gender = value;
});
}))),
Solution 1:[1]
Theme(
data: Theme.of(context).copyWith(
unselectedWidgetColor: Colors.red,
disabledColor: Colors.blue
),
Radio(
value: gender,
activeColor: Colors.white,
groupValue: _gender,
onChanged: (Gender value) {
setState(() {
_gender = value;
});
}),
)
you have to give disabledColor
Solution 2:[2]
Theme(
data: ThemeData(
toggleableActiveColor: Colors.red,
unselectedWidgetColor: Colors.grey),
child: Radio(`enter code here)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Christopher Moore |
| Solution 2 | procrastinator |

