ColorScheme constructor

const ColorScheme({
  1. required Brightness brightness,
  2. required Color primary,
  3. required Color onPrimary,
  4. Color? primaryContainer,
  5. Color? onPrimaryContainer,
  6. Color? primaryFixed,
  7. Color? primaryFixedDim,
  8. Color? onPrimaryFixed,
  9. Color? onPrimaryFixedVariant,
  10. required Color secondary,
  11. required Color onSecondary,
  12. Color? secondaryContainer,
  13. Color? onSecondaryContainer,
  14. Color? secondaryFixed,
  15. Color? secondaryFixedDim,
  16. Color? onSecondaryFixed,
  17. Color? onSecondaryFixedVariant,
  18. Color? tertiary,
  19. Color? onTertiary,
  20. Color? tertiaryContainer,
  21. Color? onTertiaryContainer,
  22. Color? tertiaryFixed,
  23. Color? tertiaryFixedDim,
  24. Color? onTertiaryFixed,
  25. Color? onTertiaryFixedVariant,
  26. required Color error,
  27. required Color onError,
  28. Color? errorContainer,
  29. Color? onErrorContainer,
  30. required Color surface,
  31. required Color onSurface,
  32. Color? surfaceDim,
  33. Color? surfaceBright,
  34. Color? surfaceContainerLowest,
  35. Color? surfaceContainerLow,
  36. Color? surfaceContainer,
  37. Color? surfaceContainerHigh,
  38. Color? surfaceContainerHighest,
  39. Color? onSurfaceVariant,
  40. Color? outline,
  41. Color? outlineVariant,
  42. Color? shadow,
  43. Color? scrim,
  44. Color? inverseSurface,
  45. Color? onInverseSurface,
  46. Color? inversePrimary,
  47. Color? surfaceTint,
  48. @Deprecated('Use surface instead. ' 'This feature was deprecated after v3.18.0-0.1.pre.') Color? background,
  49. @Deprecated('Use onSurface instead. ' 'This feature was deprecated after v3.18.0-0.1.pre.') Color? onBackground,
  50. @Deprecated('Use surfaceContainerHighest instead. ' 'This feature was deprecated after v3.18.0-0.1.pre.') Color? surfaceVariant,
})

Create a ColorScheme instance from the given colors.

ColorScheme.fromSeed can be used as a simpler way to create a full color scheme derived from a single seed color.

For the color parameters that are nullable, it is still recommended that applications provide values for them. They are only nullable due to backwards compatibility concerns.

If a color is not provided, the closest fallback color from the given colors will be used for it (e.g. primaryContainer will default to primary). Material Design 3 makes use of these colors for many component defaults, so for the best results the application should supply colors for all the parameters. An easy way to ensure this is to use ColorScheme.fromSeed to generate a full set of colors.

During the migration to Material Design 3, if an app's ThemeData.useMaterial3 is false, then components will only use the following colors for defaults:

Implementation

const ColorScheme({
  required this.brightness,
  required this.primary,
  required this.onPrimary,
  Color? primaryContainer,
  Color? onPrimaryContainer,
  Color? primaryFixed,
  Color? primaryFixedDim,
  Color? onPrimaryFixed,
  Color? onPrimaryFixedVariant,
  required this.secondary,
  required this.onSecondary,
  Color? secondaryContainer,
  Color? onSecondaryContainer,
  Color? secondaryFixed,
  Color? secondaryFixedDim,
  Color? onSecondaryFixed,
  Color? onSecondaryFixedVariant,
  Color? tertiary,
  Color? onTertiary,
  Color? tertiaryContainer,
  Color? onTertiaryContainer,
  Color? tertiaryFixed,
  Color? tertiaryFixedDim,
  Color? onTertiaryFixed,
  Color? onTertiaryFixedVariant,
  required this.error,
  required this.onError,
  Color? errorContainer,
  Color? onErrorContainer,
  required this.surface,
  required this.onSurface,
  Color? surfaceDim,
  Color? surfaceBright,
  Color? surfaceContainerLowest,
  Color? surfaceContainerLow,
  Color? surfaceContainer,
  Color? surfaceContainerHigh,
  Color? surfaceContainerHighest,
  Color? onSurfaceVariant,
  Color? outline,
  Color? outlineVariant,
  Color? shadow,
  Color? scrim,
  Color? inverseSurface,
  Color? onInverseSurface,
  Color? inversePrimary,
  Color? surfaceTint,
  @Deprecated(
    'Use surface instead. '
    'This feature was deprecated after v3.18.0-0.1.pre.'
  )
  Color? background,
  @Deprecated(
    'Use onSurface instead. '
    'This feature was deprecated after v3.18.0-0.1.pre.'
  )
  Color? onBackground,
  @Deprecated(
    'Use surfaceContainerHighest instead. '
    'This feature was deprecated after v3.18.0-0.1.pre.'
  )
  Color? surfaceVariant,
}) : _primaryContainer = primaryContainer,
     _onPrimaryContainer = onPrimaryContainer,
     _primaryFixed = primaryFixed,
     _primaryFixedDim = primaryFixedDim,
     _onPrimaryFixed = onPrimaryFixed,
     _onPrimaryFixedVariant = onPrimaryFixedVariant,
     _secondaryContainer = secondaryContainer,
     _onSecondaryContainer = onSecondaryContainer,
     _secondaryFixed = secondaryFixed,
     _secondaryFixedDim = secondaryFixedDim,
     _onSecondaryFixed = onSecondaryFixed,
     _onSecondaryFixedVariant = onSecondaryFixedVariant,
     _tertiary = tertiary,
     _onTertiary = onTertiary,
     _tertiaryContainer = tertiaryContainer,
     _onTertiaryContainer = onTertiaryContainer,
     _tertiaryFixed = tertiaryFixed,
     _tertiaryFixedDim = tertiaryFixedDim,
     _onTertiaryFixed = onTertiaryFixed,
     _onTertiaryFixedVariant = onTertiaryFixedVariant,
     _errorContainer = errorContainer,
     _onErrorContainer = onErrorContainer,
     _surfaceDim = surfaceDim,
     _surfaceBright = surfaceBright,
     _surfaceContainerLowest = surfaceContainerLowest,
     _surfaceContainerLow = surfaceContainerLow,
     _surfaceContainer = surfaceContainer,
     _surfaceContainerHigh = surfaceContainerHigh,
     _surfaceContainerHighest = surfaceContainerHighest,
     _onSurfaceVariant = onSurfaceVariant,
     _outline = outline,
     _outlineVariant = outlineVariant,
     _shadow = shadow,
     _scrim = scrim,
     _inverseSurface = inverseSurface,
     _onInverseSurface = onInverseSurface,
     _inversePrimary = inversePrimary,
     _surfaceTint = surfaceTint,
     // DEPRECATED (newest deprecations at the bottom)
     _background = background,
     _onBackground = onBackground,
     _surfaceVariant = surfaceVariant;