默认配色方案 Flutter
Default color scheme Flutter
在this教程作者展示了如何准备新的ColorScheme:
const ColorScheme _customColorScheme = ColorScheme(
primary: customMagenta50,
primaryVariant: customMagenta600,
secondary: Colors.amber,
secondaryVariant: customMagenta400,
surface: Colors.purpleAccent,
background: customSurfaceWhite,
error: customMagenta900,
onPrimary: Colors.red,
onSecondary: Colors.deepOrange,
onSurface: customMagenta300,
onBackground: customMagenta100,
onError: Colors.redAccent,
brightness: Brightness.light,
);
这个构造函数需要很多参数。我在哪里可以找到默认灯光主题中使用的默认颜色?我想使用上面的代码并仅更改一个或两个值(我在项目的下一阶段更改的另一个值)。
您可以像这样将更改应用到默认灯光 ColorScheme:
final ColorScheme _colorScheme = ColorScheme.light().copyWith(->your changes<-);
您可以在 GitHub 上查看 source-code。默认 light colorSchema
您可以使用 copyWith
构造函数。
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
colorScheme: Theme.of(context).colorScheme.copyWith(
//..here
)
),
在 copyWith(..here.)
方法中按 ctrl+space
查找属性的简单方法
您可以在 flutter.dev > ColorScheme 上找到更多详细信息。
在this教程作者展示了如何准备新的ColorScheme:
const ColorScheme _customColorScheme = ColorScheme(
primary: customMagenta50,
primaryVariant: customMagenta600,
secondary: Colors.amber,
secondaryVariant: customMagenta400,
surface: Colors.purpleAccent,
background: customSurfaceWhite,
error: customMagenta900,
onPrimary: Colors.red,
onSecondary: Colors.deepOrange,
onSurface: customMagenta300,
onBackground: customMagenta100,
onError: Colors.redAccent,
brightness: Brightness.light,
);
这个构造函数需要很多参数。我在哪里可以找到默认灯光主题中使用的默认颜色?我想使用上面的代码并仅更改一个或两个值(我在项目的下一阶段更改的另一个值)。
您可以像这样将更改应用到默认灯光 ColorScheme:
final ColorScheme _colorScheme = ColorScheme.light().copyWith(->your changes<-);
您可以在 GitHub 上查看 source-code。默认 light colorSchema
您可以使用 copyWith
构造函数。
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
colorScheme: Theme.of(context).colorScheme.copyWith(
//..here
)
),
在 copyWith(..here.)
方法中按 ctrl+space
查找属性的简单方法
您可以在 flutter.dev > ColorScheme 上找到更多详细信息。