Sai*_*imi 2 flutter iconbutton
我想要一个带有文本的图标,所以我使用了TextButton.icon
但我无法更改文本或图标的颜色!如果有人有解决方案,请建议这是我的代码:
SizedBox(height: 8,),
TextButton.icon(
icon: Icon(Icons.delete),
label: Text('delete'),
onPressed: (){},
),
Run Code Online (Sandbox Code Playgroud)
您可以在 TextButton 的样式上使用 TextButton.stylefrom。在这种方法中,您可以使用primary来设置图标和标签的颜色。如果您想为图标设置其他颜色,可以在 Icon 中设置图标颜色。
TextButton.icon(
onPressed:(){},
style: TextButton.styleFrom(
foregroundColor: Colors.blue,
),
icon: Icon(Icons.ac_unit, color: Colors.red),
label: Text("label"),
)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5680 次 |
最近记录: |