颤振材料表面颜色不适用于卡片

时间:2019-03-02 15:36:07

标签: colors flutter material-design

我正在使用Google材料构建一个Flutter应用程序。但是我无法将表面颜色应用于卡片和纸张。材料应按照material.io准则为卡片,底页和菜单应用表面颜色。

在AppColor.dart文件中将颜色定义为:

class AppColor {
  static Color primaryColor = Colors.deepPurple[500];
  static Color secondaryColor = Colors.teal[200];
  static Color accentColor = Colors.green[100];
  static Color surface = Colors.grey[200];
  static Color background = Colors.grey[50];
  static Color onPrimary = Colors.white;
  static Color onSecondary = Colors.black;
  static Color onSurface = Colors.black;
  static Color onError = Colors.white;
}

在Themes.dart文件中将表面颜色添加为灰色[200],作为

Themes.dart
static ColorScheme colorScheme = const ColorScheme.light().copyWith(
    primary: AppColor.primaryColor,
    secondary: AppColor.secondaryColor,
    surface: AppColor.surface,
    background: AppColor.background,
    onPrimary: AppColor.onPrimary,
    onSecondary: AppColor.onSecondary,
    onSurface: AppColor.onSurface,
    onBackground: AppColor.onBackground,
    onError: AppColor.onError,
  );

Appplied it in Main.dart as:

return MaterialApp(
    theme: ThemeData(
    primaryColor: AppColor.primaryColor,
    accentColor: AppColor.secondaryColor,
    colorScheme: Themes.colorScheme,
        textTheme: TextTheme(
        overline:
        TextStyle(fontFamily: AppFont.ROBOTO_MEDIUM, fontSize: 12),
        button: TextStyle(fontFamily: AppFont.ROBOTO_MEDIUM, fontSize: 14),
        caption:
        TextStyle(fontFamily: AppFont.ROBOTO_REGULAR, fontSize: 12),
        body1: TextStyle(fontFamily: AppFont.ROBOTO_REGULAR, fontSize: 14),
        body2: TextStyle(fontFamily: AppFont.ROBOTO_REGULAR, fontSize: 16),
        title: TextStyle(fontFamily: AppFont.ROBOTO_MEDIUM, fontSize: 20),

        ),
));

灰色不适用于任何表面(卡片,纸张,菜单)。卡以其默认白色显示。我必须手动更改cardcolor才能为卡片添加颜色。因此,文本在卡上的颜色也不会更改。

0 个答案:

没有答案