我有一个扩展图块列表,每个图块都有3个单选按钮。我想设置页面加载时默认选中的一些单选按钮。我怎样才能做到这一点?请帮忙。
RadioButtonGroup(
activeColor: Color(ProjectColors.mainColor),
labelStyle: TextStyle(
fontFamily: "AN",
fontSize: 16,
fontWeight: FontWeight.w400,
color: Color(ProjectColors.secondaryColor),
),
labels: _role.values.map((x) => x.title).toList(),
)
答案 0 :(得分:0)
代码如下:
String _picked = "Two"; //a variable _picked declared
RadioButtonGroup(
orientation: GroupedButtonsOrientation.HORIZONTAL,
margin: const EdgeInsets.only(left: 12.0),
onSelected: (String selected) => setState((){
_picked = selected;
}),
labels: <String>[
"One",
"Two",
],
picked: _picked,
itemBuilder: (Radio rb, Text txt, int i){
return Column(
children: <Widget>[
Icon(Icons.public),
rb,
txt,
],
);
},
),
输出: