我想制作一个图标居中的按钮。
这是我的代码。
ElevatedButton.icon(
onPressed: () {},
icon: Icon(Icons.arrow_forward),
label: Text(''),
style: ElevatedButton.styleFrom(
primary: Colors.red,
fixedSize: Size(100, 50),
)
最佳答案
试试下面的代码希望它对你有帮助。 ElevatedButton.icon 需要标签字段,请参阅文档 here你可以使用TextButton
使用容器
Container(
height: 50.0,
width: 150.0,
child: TextButton(
child: Icon(Icons.person),
onPressed: () {},
),
),
使用大小框
SizedBox(
height: 50.0,
width: 150.0,
child: TextButton(
child: Icon(Icons.person),
onPressed: () {},
),
),
关于flutter - 如何忽略 'label' 上的 'Elevated button' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69172307/