我想要一个带有文本的图标,所以我使用TextButton.icon
了但我无法更改文本或图标的颜色!请建议是否有人有解决方案这是我的代码:
SizedBox(height: 8,),
TextButton.icon(
icon: Icon(Icons.delete),
label: Text('delete'),
onPressed: (){},
),
我想要一个带有文本的图标,所以我使用TextButton.icon
了但我无法更改文本或图标的颜色!请建议是否有人有解决方案这是我的代码:
SizedBox(height: 8,),
TextButton.icon(
icon: Icon(Icons.delete),
label: Text('delete'),
onPressed: (){},
),
您可以在 TextButton 的样式上使用 TextButton.stylefrom。在这种方法中,您可以使用 primary 来设置图标和标签的颜色。如果要为图标设置另一种颜色,可以在 Icon 中设置图标颜色。
TextButton.icon(
onPressed:(){}),
style: TextButton.styleFrom(
primary: Colors.blue,
),
icon: Icon(Icons.ac_unit, color: Colors.red),
label: Text("label"),
)
试试下面的代码希望它对你有帮助。
参考TextButton
这里
TextButton.icon(
icon: Icon(
Icons.delete,
color: Colors.red,//for icon color
),
label: Text(
'Delete',
style: TextStyle(
color: Colors.red,//for text color
),
),
onPressed: () {},
),