首页 > 解决方案 > 如何在 RadioListTile 旁边放置一个按钮?- 颤振

问题描述

我想放置一个像 an 一样工作的信息按钮AlertDialog(),但我无法将其放在复选框文本旁边,因为它们组织在 a 内Column(),我不能只将 aRow()放在其中。

在此处输入图像描述

这是复选框的代码:

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

标签: androidflutterdartmobile

解决方案


在您的标题内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;
        });
      },
    ),
  ],
)

推荐阅读