class _DemoPageState extends State<DemoPage> { int groupValue = 1; @override Widget build(BuildContext context) { return Center( child: Column( //次轴居中 crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Radio( //选中颜色 activeColor: Colors.red, //值 value: 1, //当value与groupValue一致时,显示选中状态 groupValue: groupValue, onChanged: (T) { this.setState(() { groupValue = T; }); }), Radio( value: 2, groupValue: groupValue, onChanged: (T) { this.setState(() { groupValue = T; }); }), Radio( value: 3, groupValue: groupValue, onChanged: (T) { this.setState(() { groupValue = T; }); }) ], ), ); } }
部分素材资源来源网站,本站提供免费下载,如有侵权请联系站长马上删除!