gpt4 book ai didi

flutter - elevatedButtonTheme 的 textStyle 属性不会更改 ElevatedButton 中的文本颜色

转载 作者:行者123 更新时间:2023-12-04 14:46:04 25 4
gpt4 key购买 nike

我为 elevatedButtonTheme 定义了一个 textStyle

elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Color(0xff64ffda)),
textStyle: MaterialStateProperty.all(TextStyle(color: Colors.black)),
),
),

但它不会改变 ElevatedButton 文本颜色,它有什么问题吗?

它应该像我描述的那样工作吗?

child: ElevatedButton(
onPressed: _submit,
child: Padding(
child: Text(
AppLocalizations.key(context, 'save'),
),
),
),

最佳答案

从文档中,我们可以看到关于textStyle

The color of the [textStyle] is typically not used directly, the [foregroundColor] is used instead.

对于 foregroundColor

This color is typically used instead of the color of the [textStyle]. All of the components that compute defaults from [ButtonStyle] values compute a default [foregroundColor] and use that instead of the [textStyle]'s color.

用于更改按钮上的文本颜色使用 foregroundColor

更多关于 ButtonStyle

关于flutter - elevatedButtonTheme 的 textStyle 属性不会更改 ElevatedButton 中的文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70054103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com