在我的测试应用中,我有3或4个选项供您选择。因此,如下所示,我将选项放入选项中(在一个类中),但是如何调用RadioListTile?因为选择位于二维数组中。
poly_t
答案 0 :(得分:0)
尝试这样,希望对您有所帮助
String _selection = '';
List<List<String>> choices = [
["ABC", "AAB", "ACD"], // 1st qns has 3 choices
["AND", "CQA", "QWE", "QAL"], // 2nd qns has 4 choices
["ASD", "JUS", "JSB"] // 3rd qns has 3 choices
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('Question here?'),
Column(
children: choices[0].map((item) { //change index of choices array as you need
return RadioListTile(
groupValue: _selection,
title: Text(item),
value: item,
activeColor: Colors.blue,
onChanged: (val) {
print(val);
setState(() {
_selection = val;
});
},
);
}).toList(),
)
],
),
);
}