如何在 RadioListTile 旁边放置一个按钮? - 颤振

How to put a button next to a RadioListTile ? - Flutter

我想放置一个 信息按钮 ,它的工作方式与 AlertDialog() 相同,但我无法将其放在复选框文本旁边,因为它们是在 Column() 中组织,我不能只在其中放入 Row()

复选框的代码如下:

Column (
// ...
RadioListTile(
                          title: Text('Pelagens de camundongos',
                              style: TextStyle(
                                  fontSize: 17.0, color: Colors.white)),
                          value: 1,
                          groupValue: id,
                          onChanged: (val) {
                            setState(() {
                              predominant = 'recessiva_aa';
                              id = 1;
                            });
                          },
                        ),
                        const SizedBox(
                          height: 5.0,
                        ),
                        RadioListTile(
                          title: Text('Pelagem em cães labradores',
                              style: TextStyle(
                                  fontSize: 17.0, color: Colors.white)),
                          value: 2,
                          groupValue: id,
                          onChanged: (val) {
                            setState(() {
                              predominant = 'recessiva_ee';
                              id = 2;
                            });
                          },
                        ),
),

在您的 RadioListTile 的标题内,您可以放置​​一行而不是放置文本小部件,并且在该行的内部有 Text 和一个 IconButton 将弹出您的像这样按下时出现警告对话框

 Column(
  children: [
    RadioListTile(
      title: Row(
        children: [
          Text('Pelagens de camundongos',
              style: TextStyle(fontSize: 17.0, color: Colors.white)),
          IconButton(
            icon: Icon(
              Icons.info_outline,
            ),
            onPressed: () {
            // code to pop up alert dialog
            },
          ),
        ],
      ),
      value: 1,
      groupValue: id,
      onChanged: (val) {
        setState(() {
          predominant = 'recessiva_aa';
          id = 1;
        });
      },
    ),
    const SizedBox(
      height: 5.0,
    ),
    RadioListTile(
      title: Row(
        children: [
          Text('Pelagem em cães labradores',
              style: TextStyle(fontSize: 17.0, color: Colors.white)),
          IconButton(
            icon: Icon(
              Icons.info_outline,
            ),
            onPressed: () {
            // code to pop up alert dialog
            },
          ),
        ],
      ),
      value: 2,
      groupValue: id,
      onChanged: (val) {
        setState(() {
          predominant = 'recessiva_ee';
          id = 2;
        });
      },
    ),
  ],
)