ListTile在字幕中未水平显示单选按钮

时间:2020-04-17 05:14:47

标签: flutter

我想在ListTile的字幕上水平显示2个单选按钮。 我只能看到一个单选按钮。

List<QuestionsOptions> optionsList = [
QuestionsOptions(
  index: 1,
  name: "Yes",
),
QuestionsOptions(
  index: 0,
  name: "No",
),
];


      subtitle:Column(                   
                      children: [
                      new Row(                  
                        children: <Widget>[
                            Expanded(
                        child: Container(
                            child: Column(
                        children:
                        optionsList.map((data) => RadioListTile(
                          title: Text("${data.name}"),
                          groupValue: 0,
                          value: data.index,
                          onChanged: (val) {
                        //_handleWeightChange(data.name,data.index);
                        },
                      )).toList(),
                    ),
                  )),
            ],
          ),

                    ]),

如何在Listtile字幕中水平显示两个单选按钮

1 个答案:

答案 0 :(得分:1)

请在Row Widget

中添加以下代码
                        RadioListTile(
                          groupValue: selectedRadioList[index]==""?0:
                          selectedRadioList[index]=="0"?false:true,
                          title: Text('First'),
                          value: true,
                          onChanged: (val) {
                            setState(() {
                              selectedRadioList[index] = "1";

                            });

                          },
                        ),
                        RadioListTile(
                          groupValue: selectedRadioList[index]==""?0:
                          selectedRadioList[index]=="0"?false:true,
                          title: Text('Second'),
                          value: false,
                          onChanged: (val) {
                            setState(() {
                              selectedRadioList[index] = "0";
                            });

                          },
                        ),