import 'package:flutter/material.dart';
class LearnRadioButton extends StatefulWidget{
@override
State<StatefulWidget> createState() {
return new _LearnRadioButton();
}
}
class _LearnRadioButton extends State<LearnRadioButton>{
int groupValue=;
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Radio(value: , groupValue: , onChanged: null),//onChanged为null表示按钮不可用
new Radio(
value: ,
groupValue: groupValue,//当value和groupValue一致的时候则选中
activeColor: Colors.red,
onChanged: (T){
updateGroupValue(T);
}
),
new Radio(
value: ,
groupValue: groupValue,
onChanged: (T){
updateGroupValue(T);
}
),
new Radio(
value: ,
groupValue: groupValue,
onChanged: (T){
updateGroupValue(T);
}
),
new Radio(
value: ,
groupValue: groupValue,
onChanged: (T){
updateGroupValue(T);
}
),
new Radio(
value: ,
groupValue: groupValue,
onChanged: (T){
updateGroupValue(T);
}
),
new Radio(
value: ,
groupValue: groupValue,
onChanged: (T){
updateGroupValue(T);
}
),
new RadioListTile(
value: ,
groupValue: groupValue,
title: new Text('小张'),
onChanged: (T){
updateGroupValue(T);
}),
new RadioListTile(
value: ,
groupValue: groupValue,
title: new Text('小林'),
onChanged: (T){
updateGroupValue(T);
}),
new RadioListTile(
value: ,
groupValue: groupValue,
title: new Text('小王'),
onChanged: (T){
updateGroupValue(T);
}),
new RadioListTile(
value: ,
groupValue: groupValue,
title: new Text('小红'),
onChanged: (T){
updateGroupValue(T);
})
],
),
);
} void updateGroupValue(int v){
setState(() {
groupValue=v;
});
} }