class _DemoPageState extends State<DemoPage> { String value = ''; onChange(v) { this.setState(() { value = v; }); } @override Widget build(BuildContext context) { return Center( child: Column( children: [ RadioListTile( //选中颜色 activeColor: Colors.red, //标题 title: Text('星期一'), //值 value: '1', //当value==groupValue,显示选中状态 groupValue: value, //右侧图标 secondary: Icon(Icons.print), isThreeLine: false, //副标题 subtitle: Text('Monday'), onChanged: onChange ), RadioListTile( //标题 title: Text('星期二'), //值 value: '2', //右侧图标 secondary: Icon(Icons.book), //当value==groupValue,显示选中状态 groupValue: value, isThreeLine: false, //副标题 subtitle: Text('Tuesday'), onChanged: onChange ), ], ), ); } }
Flutter笔记44:RadioListTile组件
RadioListTile组件,相当与强化了radio组件,显示的内容更多,当然,用radio也能实现RadioListTile的效果,但是比较麻烦: