Flutter:如何对齐多个ButtonBar,使单选按钮位于另一个按钮的下面?

问题描述 投票:0回答:1

here you can see what I currently have:(目前不允许我插入此图片)。我在ListView中有两个带有两个单选按钮的TabBar,但是看起来很糟糕。我想将单选按钮一个放在另一个的下面,而不考虑字符串的长度。

这是我的代码:

 return ListView(
      children: <Widget>[
        //..
        ),
        Container(
            child: ButtonBar(
          alignment: MainAxisAlignment.spaceBetween, // I also tried every other setting here, but none works for me
          children: <Widget>[
            Radio(
              value: 1,
              groupValue: _selectedRadio,
              activeColor: corpColorPrimary,
              onChanged: (val) => setSelectedRadio(val),
            ),
            Text("a long String"),
            Radio(
              value: 2,
              groupValue: _selectedRadio,
              activeColor: corpColorPrimary,
              onChanged: (val) => setSelectedRadio(val),
            ),
            Text("Another long String"),
          ],
        )),

        Container(
          child: ButtonBar(
            alignment: MainAxisAlignment.start,
            children: <Widget>[
              Radio(
                value: 1,
                groupValue: _selectedRadio,
                activeColor: corpColorPrimary,
                onChanged: (val) => setSelectedRadio(val),
              ),
              Text("Hi"),
              Radio(
                value: 2,
                groupValue: _selectedRadio,
                activeColor: corpColorPrimary,
                onChanged: (val) => setSelectedRadio(val),
              ),
              Text(":)"),
            ],
          ),
        ),
        RaisedButton(
          child: Text("Next"),
          onPressed: () {},
        ),

如何正确对齐单选按钮?

flutter dart radio-button alignment buttonbar
1个回答
0
投票

您可以在每个Spacer(),小部件之间使用Container(),小部件并对其进行调整。

© www.soinside.com 2019 - 2024. All rights reserved.