Eri*_*ica 3 material-design flutter
我已从https://github.com/flutter/flutter/issues/28138重定向到这里。
通常我的问题是我不认为 FloatingActionButton backgroundColor 和 FlatButton 文本颜色是从 ThemeData 中定义的正确值继承的。
前景和背景都默认为重音颜色。
/// The color to use when filling the button.
///
/// Defaults to **[ThemeData.accentColor**] for the current theme.
final Color backgroundColor;
Run Code Online (Sandbox Code Playgroud)
我在对话框中发现了与 FlatButton 类似的问题,默认情况下,文本的颜色是强调色,即黄色(在白色背景上),如果我将其覆盖为主色,则它是红色的,但我不想让它变成红色,因为旁边的删除按钮是红色的。所以我需要将它设置为正常,所以它是黑色的,这是正确的,但是:
flat_button.dart:127
/// The color to use when filling the button.
///
/// Defaults to **[ThemeData.accentColor**] for the current theme.
final Color backgroundColor;
Run Code Online (Sandbox Code Playgroud)
我的主题:
textStyle: theme.textTheme.button.copyWith(color: buttonTheme.getTextColor(this)),
Run Code Online (Sandbox Code Playgroud)
理论上,我在弹出对话框中的 FlatButton 应该是黑色或红色。但它是黄色的强调色。
要重现尝试以下示例:https : //gist.github.com/erikkubica/45fc8acdce1f8a25cd5258e8b3a0e1f3
如果您希望浮动按钮的颜色为主要颜色,请添加以下内容。
floatingActionButton: FloatingActionButton(
backgroundColor: Theme.of(context).primaryColor,
Run Code Online (Sandbox Code Playgroud)
如果要将对话框中 FlatButton 的颜色更改为黑色,请添加以下内容。
theme: ThemeData(
colorScheme: ColorScheme.light(
primary: primary,
secondary: Colors.black,
),
Run Code Online (Sandbox Code Playgroud)
最好用 ColorScheme() 实例化它,这样它就不会影响其他小部件。
| 归档时间: |
|
| 查看次数: |
4369 次 |
| 最近记录: |