/**
* 单选框 点自己不能取消
*const Radio({
Key key,
//groupValue 与 value 相等时 Radio 被选中
@required this.value,//value 是当前Radio 的值
@required this.groupValue,//groupValue 是组的值
@required this.onChanged,
this.activeColor,//选中时的颜色
this.materialTapTargetSize,//点击区域尺寸,padded:向四周扩展48px区域;shrinkWrap:控件区域
})
*/
/**
* 系统封装的一个Radio
*
const RadioListTile({
Key key,
@required this.value,
@required this.groupValue,
@required this.onChanged,
this.activeColor,//选中颜色
this.title,
this.subtitle,
this.isThreeLine = false,//设置为true,高度变大
this.dense,
this.secondary,//左侧图标
this.selected = false,
this.controlAffinity = ListTileControlAffinity.platform,//leading:secondary在右侧;trailing:secondary在左侧;platform:根据平台确定
})
*/
body: Column(
children: <Widget>[
Radio(
value: "aaa",
groupValue: groupValue,
onChanged: (result) {
setState(() {
groupValue = result;
});
},
activeColor: Colors.red,
materialTapTargetSize: MaterialTapTargetSize.padded,
),
Radio(
value: "bbb",
groupValue: groupValue,
onChanged: (result) {
setState(() {
groupValue = result;
});
},
activeColor: Colors.red,
materialTapTargetSize: MaterialTapTargetSize.padded,
),
RadioListTile(
value: "ccc",
groupValue: groupValue,
onChanged: (result) {
setState(() {
groupValue = result;
});
},
activeColor: Colors.red,
title: Text("标题"),
subtitle: Text("副标题副标题副标题副标题副标题副标题副标题副标题副标题"),
isThreeLine: false,
secondary: Icon(Icons.alarm),
// selected:true
controlAffinity: ListTileControlAffinity.trailing,
)
],
),
网友评论