【问题标题】:How to put a button next to a RadioListTile ? - Flutter如何在 RadioListTile 旁边放置一个按钮? - 颤振
【发布时间】:2021-11-24 12:34:40
【问题描述】:

我想放置一个类似于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;
                            });
                          },
                        ),
),

【问题讨论】:

    标签: android flutter dart mobile


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2021-11-15
      • 1970-01-01
      • 2019-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-11
      相关资源
      最近更新 更多