[英]Flutter: How to Align multiple ButtonBars such that the radio buttons are one below the other?
here you can see what I currently have: (I'm currently not allowed to insert this picture).在这里你可以看到我目前拥有的:(我目前不允许插入这张图片)。 I have two TabBars with two Radio Buttons each in a ListView, but it looks horrible.
我在 ListView 中有两个 TabBar,每个都有两个 Radio Button,但它看起来很糟糕。 I would like to place the radio buttons one below the other, regardless of the length of the strings.
无论字符串的长度如何,我都想将单选按钮放在另一个下方。
Here is my code:这是我的代码:
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: () {},
),
How can I align the Radio buttons correctly?如何正确对齐单选按钮?
您可以在每个Container(),
widget 之间使用Spacer(),
Container(),
widget 并调整它们。
Take Row 和 in Row 取两列可以解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.