如何删除RadioListTile上的内部填充,以便可以连续使用3个RadioListTiles? [英] How can I remove internal padding on a RadioListTile so I can use 3 RadioListTiles in a row?
问题描述
我对Flutter和Dart很陌生,对于这个特定主题我似乎找不到任何提示.我想像这样在 Row
中放入3个 RadioListTiles
:
I am pretty new to Flutter and Dart and I can't seem to find any hints for this particular topic. I am trying to put 3 RadioListTiles
in a Row
like so:
Row(
children: [
Expanded(
child:RadioListTile<GoalSelection>(
title: Text(
'Net',
style: Theme.of(context).textTheme.body1,
),
value: GoalSelection.net,
groupValue: _goalSelection,
onChanged: (GoalSelection value) {
setState(() {
_goalSelection = value;
});
},
),
),
Expanded(
child: RadioListTile<GoalSelection>(
title: Text(
'Gross',
style: Theme.of(context).textTheme.body1,
),
value: GoalSelection.gross,
groupValue: _goalSelection,
onChanged: (GoalSelection value) {
setState(() {
_goalSelection = value;
});
},
),
),
Expanded(
child: RadioListTile<GoalSelection>(
title: Text(
'Salary',
style: Theme.of(context).textTheme.body1,
),
value: GoalSelection.salary,
groupValue: _goalSelection,
onChanged: (GoalSelection value) {
setState(() {
_goalSelection = value;
});
},
),
),
],
),
按钮布局很好,但是标签似乎浪费了很多空间.我在下面放了一个屏幕截图,它是目前的样子.我尝试将 Expanded
, RadioListTile
和 Text
包装在 Padding
小部件中(一次全部包装一次))手动将padding设置为0,但没有执行任何操作.我也尝试将 Expanded
更改为 Flexible
,即使我认为这不会改变任何东西.我现在很茫然.有什么办法可以使这种布局正常工作吗?我有点以为这是我正在做的愚蠢的事情.
The buttons layout fine, but there seems to be a lot of wasted space for the label. I put a screenshot of what it currently looks like below. I have tried wrapping the Expanded
, the RadioListTile
, and the Text
in Padding
widgets (all one at a time) to manually set the padding to 0, but it didn't do anything. I have also tried to change Expanded
to Flexible
even though I didn't think that would change anything. I am at a loss now. Is there any way to get this layout to work? I am kind of assuming it is something really dumb that I am doing.
推荐答案
RadioListTile
用于在垂直滚动列表中获取完整宽度.
RadioListTile
is used with the purpose of taking the full width in a vertical scroll list.
如果您不希望出现这种情况,请不要使用它.请改用 Radio
.
If you don't want this behavior, don't use it. Use Radio
instead.
这篇关于如何删除RadioListTile上的内部填充,以便可以连续使用3个RadioListTiles?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!