首页 > 解决方案 > 如何在 Flutter 中更改 TextButton 文本颜色

问题描述

如何在颤动中更改默认 TextButton 文本颜色是我的代码

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

标签: flutterdart

解决方案


TextButton(
    style: TextButton.styleFrom(
        backgroundColor: Colors."anyColour", // if you want to change button colour
    ),
    
    child: Text('Your Text here',
        style: TextStyle(
        color: Colors."anyColour", // this is for your text colour
    ),
),

所以你的代码是这样的,我相信

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

推荐阅读