gpt4 book ai didi

flutter - 使用Flutter RadioListTile的多项选择Qns测试应用

转载 作者:行者123 更新时间:2023-12-03 03:58:39 25 4
gpt4 key购买 nike

在我的测试应用中,我有3或4个选项供您选择。因此,如下所示,我将选项放入选项(在一个类中),但是如何调用RadioListTile?因为选择位于二维数组中。

class Test{
var 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
];
}

最佳答案

尝试这样,希望对您有所帮助

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(),
)
],
),
);
}

关于flutter - 使用Flutter RadioListTile的多项选择Qns测试应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58956729/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com