【发布时间】:2020-09-13 13:29:10
【问题描述】:
我正在寻找 Flutter 中的自定义颜色主题模式。类似于Swift 中写的以下内容。
struct Colors {
struct Text {
static var success: UIColor {
return UIColor.green
}
static var error: UIColor {
return UIColor.red
}
}
struct Button {
static var normal: UIColor {
return UIColor.black
}
static var onPressed: UIColor {
return UIColor.blue
}
}
}
这样我就可以使用类似的东西,
let successTextColor = Colors.Text.success
let normalButtonColor = Colors.Button.normal
>主要目标:
我正在寻找适合或最适合flutter项目的东西,以上仅供参考。
我尝试过覆盖ThemeData,但据我了解,我只能覆盖TextTheme,不能使用任何自定义值,例如errorText或successText等。
我想要一些可以为我提供按钮或其他小部件的颜色(字体、大小等)的东西。
还要记住,我需要支持明暗主题。
任何建议都将不胜感激。
【问题讨论】:
标签: android ios flutter mobile flutter-theme