Flutter基础组件RadioListTile
程序员文章站
2022-05-30 19:32:48
...
标题Flutter基础组件RadioListTile
1.组件属性介绍
2.不同属性效果比较
3.完整代码
///单选列表
class RadioListTileView extends StatefulWidget {
@override
_RadioListTileViewState createState() => _RadioListTileViewState();
}
class _RadioListTileViewState extends State<RadioListTileView> {
String defaultValue = "A";
onChange(value) {
if (mounted)
setState(() {
defaultValue = value;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("RadioListTileView"),
),
body: Column(
children: <Widget>[
Container(
color: Colors.red,
child: RadioListTile<String>(
value: "A",
title: Text("A选项"),
subtitle: Text(
"A选项的二级标签项",
style: TextStyle(fontSize: 16),
),
dense: false,
isThreeLine: true,
// secondary: Text("这是一个居右的组件"),
secondary: Icon(Icons.send),
selected: true,
groupValue: defaultValue,
onChanged: (v) => onChange(v),
),
),
Container(
color: Colors.green,
child: RadioListTile<String>(
value: "B",
title: Text("B选项"),
subtitle: Text(
"B选项的二级标签",
style: TextStyle(fontSize: 16),
),
dense: true,
groupValue: defaultValue,
onChanged: (v) => onChange(v),
),
),
RadioListTile<String>(
value: "C",
title: Text("C选项"),
subtitle: Text(
"C选项的二级标签",
style: TextStyle(fontSize: 16),
),
groupValue: defaultValue,
onChanged: (v) => onChange(v),
)
],
),
);
}
}
4.补充:选中颜色属性activeColor
上一篇: 火币杨锦炎:STO将开启区块链产业下半场
下一篇: 辉煌控股解读数字货币怎么投资才能盈利?