Flutter-如何更改无线电背景色 [英] Flutter - how to change radio background color
本文介绍了Flutter-如何更改无线电背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
默认情况下,Flutter收音机的背景是透明的,可以更改它吗?
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;
});
}))),
推荐答案
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;
});
}),
)
您必须提供disabledColor
这篇关于Flutter-如何更改无线电背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文