如何删除 RadioListTile 上的内部填充,以便可以连续使用 3 个 RadioListTiles? [英] How can I remove internal padding on a RadioListTile so I can use 3 RadioListTiles in a row?
问题描述
我对 Flutter 和 Dart 很陌生,我似乎找不到任何关于这个特定主题的提示.我正在尝试将 3 个 RadioListTiles
放在 Row
中,如下所示:
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
小部件中(一次一个) 手动将填充设置为 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.
推荐答案
您可以连续使用 Radio
和 Text
小部件.但是 Radio
也有同样的填充问题.要删除填充,您可以将 Radio
作为 SizedBox
的子项.
You can use a Radio
and Text
widget in a row. But the Radio
also has the same padding problem. To remove the padding you can put the Radio
as a child of a SizedBox
.
eg:- SizedBox(height: 20, width: 20, child: Radio(.......))
这篇关于如何删除 RadioListTile 上的内部填充,以便可以连续使用 3 个 RadioListTiles?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!