fromSeeds static method

ColorScheme fromSeeds({
  1. Brightness brightness = Brightness.light,
  2. required Color primaryKey,
  3. Color? secondaryKey,
  4. Color? tertiaryKey,
  5. Color? errorKey,
  6. Color? neutralKey,
  7. Color? neutralVariantKey,
  8. FlexTones? tones,
  9. Color? primary,
  10. Color? onPrimary,
  11. Color? primaryContainer,
  12. Color? onPrimaryContainer,
  13. Color? secondary,
  14. Color? onSecondary,
  15. Color? secondaryContainer,
  16. Color? onSecondaryContainer,
  17. Color? tertiary,
  18. Color? onTertiary,
  19. Color? tertiaryContainer,
  20. Color? onTertiaryContainer,
  21. Color? error,
  22. Color? onError,
  23. Color? errorContainer,
  24. Color? onErrorContainer,
  25. Color? background,
  26. Color? onBackground,
  27. Color? surface,
  28. Color? onSurface,
  29. Color? surfaceVariant,
  30. Color? onSurfaceVariant,
  31. Color? outline,
  32. Color? outlineVariant,
  33. Color? shadow,
  34. Color? scrim,
  35. Color? inverseSurface,
  36. Color? onInverseSurface,
  37. Color? inversePrimary,
  38. Color? surfaceTint,
})

Returns a ColorScheme from seed keys primaryKey, secondaryKey, tertiaryKey, errorKey, neutralKey and neutralVariantKey colors.

Use FlexTones configuration to customize tone mapping from tonal palettes to ColorScheme color and key color chroma usage, per key color for the tonal palette creation.

Any seed produced ColorScheme color can be overridden by providing it a given Color value.

Implementation

static ColorScheme fromSeeds({
  /// The overall brightness of this color scheme.
  Brightness brightness = Brightness.light,

  /// Seed color used to generate all the primary color dependent colors in
  /// a ColorScheme.
  ///
  /// In Material 3 color system and in [ColorScheme.fromSeed], this color is
  /// used to generate palettes for all tonal palettes, except error palette
  /// that has its own fixed seed value.
  ///
  /// The default is the same here. However, if colors are provided for
  /// [secondaryKey] and [tertiaryKey] their tonal palettes will be seeded
  /// from their own key color. Likewise for [errorKey], [neutralKey] and
  /// the [neutralVariantKey] colors. It is however uncommon and seldom
  /// needed to customize them, but to create very custom an unique looking
  /// apps, it is possible to do so.
  ///
  /// As in [ColorScheme.fromSeed], there is no guarantee that the used key
  /// color, used as seed, ends up as the corresponding main color in the
  /// produced [ColorScheme] for the palette in question. In this case
  /// [primaryKey] will typically not become your [ColorScheme.primary] color.
  /// It will only be of the same hue. If you used a color intended for light
  /// theme mode as [primaryKey], consider overriding [primary] for the light
  /// theme with the same color value as your [primaryKey].
  required Color primaryKey,

  /// Optional key color used to seed the secondary tonal palette.
  ///
  /// There is no guarantee that the used key
  /// color used as seed, ends up as the corresponding main color in the
  /// produced [ColorScheme] for the palette in question. In this case
  /// [secondaryKey] will typically not become your [ColorScheme.secondary]
  /// color. It will only be of the same hue. If you used a color intended
  /// for light theme mode as [secondaryKey], consider overriding [secondary]
  /// for the light theme with the same color value as your [secondaryKey].
  Color? secondaryKey,

  /// Optional key color used to seed the tertiary tonal palette.
  ///
  /// There is no guarantee that the used key
  /// color used as seed, ends up as the corresponding main color in the
  /// produced [ColorScheme] for the palette in question. In this case
  /// [tertiaryKey] will typically not become your [ColorScheme.tertiary]
  /// color. It will only be of the same hue. If you used a color intended
  /// for light theme mode as [tertiaryKey], consider overriding [tertiary]
  /// for the light theme with the same color value as your [tertiaryKey].
  Color? tertiaryKey,

  /// Optional key color used to seed the error tonal palette.
  ///
  /// There is no guarantee that the used key
  /// color used as seed, ends up as the corresponding main color in the
  /// produced [ColorScheme] for the palette in question. In this case
  /// [errorKey] will typically not become your [ColorScheme.error]
  /// color. It will only be of the same hue. If you used a color intended
  /// for light theme mode as [errorKey], consider overriding [error]
  /// for the light theme with the same color value as your [errorKey].
  Color? errorKey,

  /// Optional key color used to seed the neutral tonal palette.
  ///
  /// There is no guarantee that the used key
  /// color used as seed, ends up as the corresponding main color in the
  /// produced [ColorScheme] for the palette in question. In this case
  /// [neutralKey] will typically not become your [ColorScheme.surface]
  /// color. It will only be of the same hue. If you used a color intended
  /// for light theme mode as [neutralKey], consider overriding [surface]
  /// for the light theme with the same color value as your [neutralKey].
  Color? neutralKey,

  /// Optional key color used to seed the neutral variant tonal palette.
  ///
  /// There is no guarantee that the used key
  /// color used as seed, ends up as the corresponding main color in the
  /// produced [ColorScheme] for the palette in question. In this case
  /// [neutralVariantKey] will typically not become your
  /// [ColorScheme.surfaceVariant] color. It will only be of the same hue.
  /// If you used a color intended for light theme mode as
  /// [neutralVariantKey], consider overriding [surfaceVariant] for the light
  /// theme with the same color value as your [neutralVariantKey].
  Color? neutralVariantKey,

  /// Tonal palette chroma usage configuration and mapping to [ColorScheme].
  ///
  /// Optional mapping configuration for how tonal palette tones are mapped
  /// to their corresponding [ColorScheme] colors.
  ///
  /// Can also configure how chroma is limited or fixed from the provided
  /// key colors when generating each tonal palette.
  ///
  /// If not provided, a setup matching the Material 3 Color System
  /// specification is used. To create seed generated [ColorScheme] with
  /// different chroma limits and tonal mappings provide a custom [FlexTones],
  /// or use a predefined one like [FlexTones.jolly], [FlexTones.vivid] or
  /// [FlexTones.highContrast].
  FlexTones? tones,

  /// Override color for the seed generated [primary] color.
  ///
  /// You may want to assign the [primaryKey] to this color in light
  /// brightness mode, if it is also your branding or main design color.
  Color? primary,

  /// Override color for the seed generated [onPrimary] color.
  Color? onPrimary,

  /// Override color for the seed generated [primaryContainer] color.
  Color? primaryContainer,

  /// Override color for the seed generated [onPrimaryContainer] color.
  Color? onPrimaryContainer,

  /// Override color for the seed generated [secondary] color.
  ///
  /// You may sometimes want to assign the [secondaryKey] to this color in
  /// light brightness mode, if it is also your secondary brand or design
  /// color.
  ///
  /// If you only have two brand or design colors, consider using it as key
  /// color and override for the tertiary color instead, as the M3 color
  /// system calls for a secondary color that is same or close in hue to the
  /// primary color but with less chroma. Your secondary brand or design color
  /// may not fit well with that constraint. The tertiary color in M3 color
  /// system does not have this preference.
  Color? secondary,

  /// Override color for the seed generated [onSecondary] color.
  Color? onSecondary,

  /// Override color for the seed generated [secondaryContainer] color.
  Color? secondaryContainer,

  /// Override color for the seed generated [onSecondaryContainer] color.
  Color? onSecondaryContainer,

  /// Override color for the seed generated [tertiary] color.
  ///
  /// You may sometimes want to assign the [tertiaryKey] to this color in
  /// light brightness mode, if it is also your secondary or tertiary brand
  /// or design color.
  ///
  /// If you only have two brand or design colors, consider using it as
  /// key color and override for the tertiary color, as the M3 color
  /// system calls for a secondary color that is same or close in hue to the
  /// primary color but with less chroma. Your secondary brand or design color
  /// may not fit well with that constraint. The tertiary color in M3 color
  /// system does not have this preference.
  Color? tertiary,

  /// Override color for the seed generated [onTertiary] color.
  Color? onTertiary,

  /// Override color for the seed generated [tertiaryContainer] color.
  Color? tertiaryContainer,

  /// Override color for the seed generated [onTertiaryContainer] color.
  Color? onTertiaryContainer,

  /// Override color for the seed generated [error] color.
  Color? error,

  /// Override color for the seed generated [onError] color.
  Color? onError,

  /// Override color for the seed generated [errorContainer] color.
  Color? errorContainer,

  /// Override color for the seed generated [onErrorContainer] color.
  Color? onErrorContainer,

  /// Override color for the seed generated [background] color.
  Color? background,

  /// Override color for the seed generated [onBackground] color.
  Color? onBackground,

  /// Override color for the seed generated [surface] color.
  Color? surface,

  /// Override color for the seed generated [onSurface] color.
  Color? onSurface,

  /// Override color for the seed generated [surfaceVariant] color.
  Color? surfaceVariant,

  /// Override color for the seed generated [onSurfaceVariant] color.
  Color? onSurfaceVariant,

  /// Override color for the seed generated [outline] color.
  Color? outline,

  /// Override color for the seed generated [outlineVariant] color.
  Color? outlineVariant,

  /// Override color for the seed generated [shadow] color.
  Color? shadow,

  /// Override color for the seed generated [scrim] color.
  Color? scrim,

  /// Override color for the seed generated [inverseSurface] color.
  Color? inverseSurface,

  /// Override color for the seed generated [onInverseSurface] color.
  Color? onInverseSurface,

  /// Override color for the seed generated [inversePrimary] color.
  Color? inversePrimary,

  /// Override color for the seed generated [surfaceTint] color.
  Color? surfaceTint,
}) {
  final FlexSeedScheme scheme = brightness == Brightness.light
      ? FlexSeedScheme._tones(
          primaryKey: primaryKey.value,
          secondaryKey: secondaryKey?.value,
          tertiaryKey: tertiaryKey?.value,
          errorKey: errorKey?.value,
          neutralKey: neutralKey?.value,
          neutralVariantKey: neutralVariantKey?.value,
          tones: tones ?? FlexTones.material(Brightness.light),
        )
      : FlexSeedScheme._tones(
          primaryKey: primaryKey.value,
          secondaryKey: secondaryKey?.value,
          tertiaryKey: tertiaryKey?.value,
          errorKey: errorKey?.value,
          neutralKey: neutralKey?.value,
          neutralVariantKey: neutralVariantKey?.value,
          tones: tones ?? FlexTones.material(Brightness.dark),
        );
  return ColorScheme(
    primary: primary ?? Color(scheme.primary),
    onPrimary: onPrimary ?? Color(scheme.onPrimary),
    primaryContainer: primaryContainer ?? Color(scheme.primaryContainer),
    onPrimaryContainer:
        onPrimaryContainer ?? Color(scheme.onPrimaryContainer),
    secondary: secondary ?? Color(scheme.secondary),
    onSecondary: onSecondary ?? Color(scheme.onSecondary),
    secondaryContainer:
        secondaryContainer ?? Color(scheme.secondaryContainer),
    onSecondaryContainer:
        onSecondaryContainer ?? Color(scheme.onSecondaryContainer),
    tertiary: tertiary ?? Color(scheme.tertiary),
    onTertiary: onTertiary ?? Color(scheme.onTertiary),
    tertiaryContainer: tertiaryContainer ?? Color(scheme.tertiaryContainer),
    onTertiaryContainer:
        onTertiaryContainer ?? Color(scheme.onTertiaryContainer),
    error: error ?? Color(scheme.error),
    onError: onError ?? Color(scheme.onError),
    errorContainer: errorContainer ?? Color(scheme.errorContainer),
    onErrorContainer: onErrorContainer ?? Color(scheme.onErrorContainer),
    background: background ?? Color(scheme.background),
    onBackground: onBackground ?? Color(scheme.onBackground),
    surface: surface ?? Color(scheme.surface),
    onSurface: onSurface ?? Color(scheme.onSurface),
    surfaceVariant: surfaceVariant ?? Color(scheme.surfaceVariant),
    onSurfaceVariant: onSurfaceVariant ?? Color(scheme.onSurfaceVariant),
    outline: outline ?? Color(scheme.outline),
    outlineVariant: outlineVariant ?? Color(scheme.outlineVariant),
    shadow: shadow ?? Color(scheme.shadow),
    scrim: scrim ?? Color(scheme.scrim),
    inverseSurface: inverseSurface ?? Color(scheme.inverseSurface),
    onInverseSurface: onInverseSurface ?? Color(scheme.onInverseSurface),
    inversePrimary: inversePrimary ?? Color(scheme.inversePrimary),
    surfaceTint: surfaceTint ?? Color(scheme.primary),
    brightness: brightness,
  );
}