简体   繁体   English

如何更改 Flutter 中的 TextButton 文本颜色

[英]How to change TextButton text color in Flutter

How to change default TextButton text color in flutter here is my code如何更改 flutter 中的默认 TextButton 文本颜色这是我的代码

TextButton(onPressed: null, child: Text('Add Item'))

Just add style property to Text constructor if you are not using a theme如果您不使用主题,只需将样式属性添加到 Text 构造函数

TextButton(onPressed: null, child: Text('Add Item', 
style: TextStyle(color: Colors.purple)))

If You are using the default theme in the main.dart file then it will pick the accentColor or u can manually also provide如果您在 main.dart 文件中使用默认主题,那么它将选择强调颜色,或者您也可以手动提供

TextButton(onPressed: null, child: Text('Add Item', 
style: TextStyle(color: Theme.of(context).accentColor)))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM