How to change radio's inactive color in Flutter?
Radio
uses unselectedWidgetColor
of ThemeData
. If you need to change it only for a few radios on a specific screen, wrap them in Theme
widget to override a color:
Theme( data: Theme.of(context).copyWith( unselectedWidgetColor: Colors.red, disabledColor: Colors.blue ), child: Column( children: <Widget>[ ListTile( onTap: () => setState(() => value = 0), leading: Radio( value: 0, groupValue: value, onChanged: (v) => setState(() => value = v), ) ), ListTile( onTap: () => setState(() => value = 1), leading: Radio( value: 1, groupValue: value, onChanged: (v) => setState(() => value = v), ) ), ], ),)
If no callback passed in onChanged
to Radio
, it is interpreted as disabled (this works for many default material widgets).
You can also set the fillColor
propery, it resolves a color for multiple radio states. In this case, it returns Colors.blue
for all states.
Radio( fillColor: MaterialStateColor.resolveWith((states) => Colors.blue), value: 1, groupValue: _optionValue, onChanged: changeValue, )