我正试图增加按钮栏按钮的宽度,所以我使用了buttonMinWidth,但由于某种原因,它不起作用,这是我的代码:
ButtonBar(
children: [
TextButton.icon(
onPressed: null,
icon: const Icon(
Icons.replay,
color: Colors.red,
),
label: const Text(
"Retry",
style: TextStyle(color: Colors.red),
),
),
TextButton.icon(
onPressed: null,
icon: const Icon(
Icons.replay,
color: Colors.green,
),
label: const Text(
"Continue",
style: TextStyle(color: Colors.green),
),
),
],
buttonMinWidth: 100,
),
这可能很简单,但我似乎找不到问题所在。
您可以用SizedBox小部件包装ButtonBar小部件,并可以指定宽度。但我不认为这是最好的解决方案,但这会解决你的问题。
SizedBox(
width: 300,
child: ButtonBar(
children: [
TextButton.icon(
onPressed: null,
icon: const Icon(
Icons.replay,
color: Colors.red,
),
label: const Text(
"Retry",
style: TextStyle(color: Colors.red),
),
),
TextButton.icon(
onPressed: null,
icon: const Icon(
Icons.replay,
color: Colors.green,
),
label: const Text(
"Continue",
style: TextStyle(color: Colors.green),
),
),
],
),
),