【发布时间】:2021-06-12 17:45:32
【问题描述】:
我最近将代码基础切换到了 Flutter 2。
- 设备状态栏图标的颜色为黑色
- TextField 的上下文菜单项的颜色为黑色
以前它们是白色的,所以在新的 Flutter 版本中似乎有所改变。
我正在使用ThemaData.dark() 和一些特定的颜色。特别是我将cardColor 设置为深灰色,为TextField 的上下文菜单的背景着色:
ThemeData buildTheme() {
final ThemeColors colors = themeColors();
final ThemeData base = ThemeData.dark();
return ThemeData(
scaffoldBackgroundColor: colors.primaryBackground(), // == dark grey
primaryColor: colors.primaryBackground(), // == dark grey
accentColor: colors.accent(), // == orange
textTheme: base.textTheme,
buttonTheme: base.buttonTheme.copyWith(
buttonColor: colors.accent(), // == orange
textTheme: ButtonTextTheme.primary
canvasColor: colors.inputBackground(), // == dark grey
inputDecorationTheme: base.inputDecorationTheme.copyWith(
hintStyle: TextStyle(color: colors.textFieldHintText()), // == grey
fillColor: colors.inputBackground(), // == dark grey
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: colors.focused())), // == green
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: colors.accent())), // == orange
),
unselectedWidgetColor: colors.accent(), // == orange
cardColor: colors.messageBackground()); // == dark grey
}
- 你知道为什么在使用新的 Flutter 版本时描述的颜色不会变成白色吗?
- 你知道我能做些什么来解决这个问题吗?是否可以更改
ThemeData的另一个颜色字段?
我唯一的想法是删除 cardColor 更改,这会产生一个白色的上下文菜单。但这并不能解决状态栏的文字颜色问题。
【问题讨论】:
标签: flutter user-interface colors themes