FlexTones class
Configuration data class that defines which tone to use from each FlexTonalPalette when assigning used color to each ColorScheme color.
It is also possible to define how Cam16 chroma is used and limited when generating the tonal palette.
To use optional FlexTones to change tone mappings and default chroma
usage and limits with SeedColorScheme.fromSeeds, you can pass in one of
the predefined configs below, to its tones
property:
-
FlexTones.material, default and same as Flutter SDK M3 setup used in Flutter 3.22 and later.
-
FlexTones.material3Legacy, the same as Flutter SDK M3 setup used in Flutter 3.19 and earlier.
-
FlexTones.soft, softer and earthier tones than M3 FlexTones.material.
-
FlexTones.vivid, more vivid colors, uses chroma from all key colors.
-
FlexTones.vividSurfaces, like vivid, but with more colors in surfaces.
-
FlexTones.vividBackground, like vividSurfaces, but with tone mapping for
Colorscheme.surface
andColorscheme.background
colors swapped. -
FlexTones.highContrast, can be used for more color accessible themes.
-
FlexTones.ultraContrast, for a very high contrast theme that is still in Material 3 color system style.
-
FlexTones.jolly, for a more "jolly" and colorful theme.
-
FlexTones.oneHue, to create one hue schemes from a primary seed color. When only a primary seed color is used the tertiary color is not rotated 60 degrees as with the all the other tone mapping to create the tertiary hue when a key for it is not provided, the primary hue is used. We can thus create a color scheme that uses only one hue.
-
FlexTones.candyPop for a high contrast, candy popping theme. It has tone 100, which is white surface and background in light mode and very dark tone 6, dark mode.
-
FlexTones.chroma for a theme where the chroma in each seed color is used as is with any min limitation. Chroma in passed in color can even be zero, producing a greyscale tonal palette as the palette. It has tone 100, which is white surface and background in light mode and very dark tone 6, dark mode.
-
In version 2.0.0 and later all built-in FlexTones use the paletteType extended via FlexPaletteType.extended, for additional tone fidelity. This is needed for compatibility with Flutter 3.22 and its revised ColorScheme.
You can also easily create custom configurations by using the FlexTones.light and FlexTones.dark factories that have defaults that match the Material 3 design setup tone mapping wise, but don't lock chroma by default for primary, secondary and tertiary key colors. Modify the properties you want to change. The above pre-made constructors are examples of doing this.
When FlexTonalPalettes are generated from key color(s) and used to define a ColorScheme, it is recommended to use the same key colors and FlexTones setup for both the light and dark theme. By doing so the same FlexTonalPalette is used to assign suitable tones from identical FlexTonalPalette, but using different tones for light and dark Brightness.
The FlexTones.light and FlexTones.dark constructors match the definition used by Material Design 3 based seed generated tones, for the tone mapping, however chroma is by default unbound. Use FlexTones.material, for an exact match.
In Flutter SDK this tone mapping and chroma setup is done with hard coded values in ColorScheme.fromSeed and libraries it uses. This class offers configuration of those tone mapping parameters. Depending on which color in the ColorScheme it concerns, mapping can typically be changed one step in either direction for a slightly different result. In some cases two tone steps can also be used. Three steps is rarely a good idea, but doable in a few select cases. Avoid going much further than that with any default tone mapping adjustments.
- Mixed-in types
- Annotations
Constructors
- FlexTones({required int primaryTone, required int onPrimaryTone, required int primaryContainerTone, required int onPrimaryContainerTone, required int primaryFixedTone, required int primaryFixedDimTone, required int onPrimaryFixedTone, required int onPrimaryFixedVariantTone, required int secondaryTone, required int onSecondaryTone, required int secondaryContainerTone, required int onSecondaryContainerTone, required int secondaryFixedTone, required int secondaryFixedDimTone, required int onSecondaryFixedTone, required int onSecondaryFixedVariantTone, required int tertiaryTone, required int onTertiaryTone, required int tertiaryContainerTone, required int onTertiaryContainerTone, required int tertiaryFixedTone, required int tertiaryFixedDimTone, required int onTertiaryFixedTone, required int onTertiaryFixedVariantTone, required int errorTone, required int onErrorTone, required int errorContainerTone, required int onErrorContainerTone, required int surfaceTone, required int surfaceDimTone, required int surfaceBrightTone, required int surfaceContainerLowestTone, required int surfaceContainerLowTone, required int surfaceContainerTone, required int surfaceContainerHighTone, required int surfaceContainerHighestTone, required int onSurfaceTone, required int onSurfaceVariantTone, required int outlineTone, required int outlineVariantTone, required int shadowTone, required int scrimTone, required int inverseSurfaceTone, required int onInverseSurfaceTone, required int inversePrimaryTone, required int surfaceTintTone, @Deprecated('Use surfaceTone instead.') int? backgroundTone, @Deprecated('Use onSurfaceTone instead.') int? onBackgroundTone, @Deprecated('Use surfaceContainerHighestTone instead.') int? surfaceVariantTone, double? primaryChroma, double? primaryMinChroma, double? secondaryChroma, double? secondaryMinChroma, double? tertiaryChroma, double? tertiaryMinChroma, double? tertiaryHueRotation, double? errorChroma, double? errorMinChroma, double? neutralChroma, double? neutralMinChroma, double? neutralVariantChroma, double? neutralVariantMinChroma, FlexPaletteType paletteType = FlexPaletteType.extended, bool useCam16 = true})
-
Default constructor requiring almost all properties.
const
- FlexTones.candyPop(Brightness brightness)
-
Creates a tonal palette setup that results in a high contrast colorful
candy pop like theme.
factory
- FlexTones.chroma(Brightness brightness)
-
Creates a tonal palette setup that result in a color scheme that follows
chroma of each used seed color. Useful for manual control of pop or low
chromacity.
factory
- FlexTones.dark({int primaryTone = 80, int onPrimaryTone = 20, int primaryContainerTone = 30, int onPrimaryContainerTone = 90, int primaryFixedTone = 90, int primaryFixedDimTone = 80, int onPrimaryFixedTone = 10, int onPrimaryFixedVariantTone = 30, int secondaryTone = 80, int onSecondaryTone = 20, int secondaryContainerTone = 30, int onSecondaryContainerTone = 90, int secondaryFixedTone = 90, int secondaryFixedDimTone = 80, int onSecondaryFixedTone = 10, int onSecondaryFixedVariantTone = 30, int tertiaryTone = 80, int onTertiaryTone = 20, int tertiaryContainerTone = 30, int onTertiaryContainerTone = 90, int tertiaryFixedTone = 90, int tertiaryFixedDimTone = 80, int onTertiaryFixedTone = 10, int onTertiaryFixedVariantTone = 30, int errorTone = 80, int onErrorTone = 20, int errorContainerTone = 30, int onErrorContainerTone = 90, int surfaceTone = 6, int surfaceDimTone = 6, int surfaceBrightTone = 24, int surfaceContainerLowestTone = 4, int surfaceContainerLowTone = 10, int surfaceContainerTone = 12, int surfaceContainerHighTone = 17, int surfaceContainerHighestTone = 22, int onSurfaceTone = 90, int onSurfaceVariantTone = 80, int inverseSurfaceTone = 90, int onInverseSurfaceTone = 20, int inversePrimaryTone = 40, int surfaceTintTone = 80, int outlineTone = 60, int outlineVariantTone = 30, int shadowTone = 0, int scrimTone = 0, @Deprecated('Use surfaceTone instead.') int? backgroundTone, @Deprecated('Use onSurfaceTone instead.') int? onBackgroundTone, @Deprecated('Use surfaceContainerHighestTone instead.') int? surfaceVariantTone, double? primaryChroma, double? primaryMinChroma, double? secondaryChroma, double? secondaryMinChroma, double? tertiaryChroma, double? tertiaryMinChroma, double? tertiaryHueRotation, double? errorChroma, double? errorMinChroma, double? neutralChroma = 6, double? neutralMinChroma, double? neutralVariantChroma = 8, double? neutralVariantMinChroma, FlexPaletteType paletteType = FlexPaletteType.extended, bool useCam16 = true})
-
Create a M3 standard dark tonal palette tones extraction setup.
const
- FlexTones.highContrast(Brightness brightness)
-
Creates a tonal palette extraction setup that results in M3 like
ColorsSchemes with high contrast between color versus its on-color and
main color, versus its container color.
factory
- FlexTones.jolly(Brightness brightness)
-
Creates a tonal palette extraction setup that results in a more jolly
colorful ColorsSchemes.
factory
- FlexTones.light({int primaryTone = 40, int onPrimaryTone = 100, int primaryContainerTone = 90, int onPrimaryContainerTone = 10, int primaryFixedTone = 90, int primaryFixedDimTone = 80, int onPrimaryFixedTone = 10, int onPrimaryFixedVariantTone = 30, int secondaryTone = 40, int onSecondaryTone = 100, int secondaryContainerTone = 90, int onSecondaryContainerTone = 10, int secondaryFixedTone = 90, int secondaryFixedDimTone = 80, int onSecondaryFixedTone = 10, int onSecondaryFixedVariantTone = 30, int tertiaryTone = 40, int onTertiaryTone = 100, int tertiaryContainerTone = 90, int onTertiaryContainerTone = 10, int tertiaryFixedTone = 90, int tertiaryFixedDimTone = 80, int onTertiaryFixedTone = 10, int onTertiaryFixedVariantTone = 30, int errorTone = 40, int onErrorTone = 100, int errorContainerTone = 90, int onErrorContainerTone = 10, int surfaceTone = 98, int surfaceDimTone = 87, int surfaceBrightTone = 98, int surfaceContainerLowestTone = 100, int surfaceContainerLowTone = 96, int surfaceContainerTone = 94, int surfaceContainerHighTone = 92, int surfaceContainerHighestTone = 90, int onSurfaceTone = 10, int onSurfaceVariantTone = 30, int inverseSurfaceTone = 20, int onInverseSurfaceTone = 95, int inversePrimaryTone = 80, int surfaceTintTone = 40, int outlineTone = 50, int outlineVariantTone = 80, int shadowTone = 0, int scrimTone = 0, @Deprecated('Use surfaceTone instead.') int? backgroundTone, @Deprecated('Use onSurfaceTone instead.') int? onBackgroundTone, @Deprecated('Use surfaceContainerHighestTone instead.') int? surfaceVariantTone, double? primaryChroma, double? primaryMinChroma, double? secondaryChroma, double? secondaryMinChroma, double? tertiaryChroma, double? tertiaryMinChroma, double? tertiaryHueRotation, double? errorChroma, double? errorMinChroma, double? neutralChroma = 6, double? neutralMinChroma, double? neutralVariantChroma = 8, double? neutralVariantMinChroma, FlexPaletteType paletteType = FlexPaletteType.extended, bool useCam16 = true})
-
Create an M3 light theme mode tonal palette tones extraction setup.
const
- FlexTones.material(Brightness brightness)
-
Create a Material-3 standard tonal palette tones extraction using HCT
based chroma.
factory
- FlexTones.material3Legacy(Brightness brightness)
-
Create a Material-3 standard tonal palette tones extraction using Cam16
based chroma.
factory
- FlexTones.oneHue(Brightness brightness)
-
Create a Material-3 tonal palette tones extraction, but with no hue
rotation from primary if no ARGB key color is provided for tertiary
palette.
factory
- FlexTones.soft(Brightness brightness)
-
Creates a tonal palette extraction setup that results in M3 like
ColorsSchemes with softer colors than Material-3 defaults.
factory
- FlexTones.ultraContrast(Brightness brightness)
-
Creates a tonal palette extraction setup that results in a very high
contrast version of selected ColorsSchemes.
factory
- FlexTones.vivid(Brightness brightness)
-
Creates a tonal palette extraction setup that results in M3 like
ColorsSchemes with more vivid colors.
factory
- FlexTones.vividBackground(Brightness brightness)
-
Creates a tonal palette extraction setup that results in M3 like
ColorsSchemes with chroma like FlexTones.vividSurfaces, but with a few
minor adjustments for increased contrast in dark mode and no tinted
surface color in light mode.
factory
- FlexTones.vividSurfaces(Brightness brightness)
-
Creates a tonal palette extraction setup that results in M3 like
ColorsSchemes with chroma like FlexTones.vivid on main colors, but
increased chroma on neutrals and more color tinted surfaces and onColors.
factory
Properties
- backgroundTone → int?
-
Tone used for ColorScheme background from neutral FlexTonalPalette.
final
- errorChroma → double?
-
Cam16 chroma value to use for error colors FlexTonalPalette
generation.
final
- errorContainerTone → int
-
Tone used for ColorScheme.errorContainer from error FlexTonalPalette.
final
- errorMinChroma → double?
-
The minimum used error chroma value.
final
- errorTone → int
-
Tone used for ColorScheme.error from error FlexTonalPalette.
final
- hashCode → int
-
Override for hashcode, dart.ui Jenkins based.
no setteroverride
- inversePrimaryTone → int
-
Tone used for ColorScheme.inversePrimary from primary
FlexTonalPalette.
final
- inverseSurfaceTone → int
-
Tone used for ColorScheme.inverseSurface from neutral
FlexTonalPalette.
final
- neutralChroma → double?
-
Cam16 chroma value to use for neutral colors FlexTonalPalette
generation.
final
- neutralMinChroma → double?
-
The minimum used neutral chroma value.
final
- neutralVariantChroma → double?
-
Cam16 chroma value to use for neutral colors FlexTonalPalette
generation.
final
- neutralVariantMinChroma → double?
-
The minimum used neutral variant chroma value.
final
- onBackgroundTone → int?
-
Tone used for ColorScheme onBackground from neutral FlexTonalPalette.
final
- onErrorContainerTone → int
-
Tone used for ColorScheme.onErrorContainer from error
FlexTonalPalette.
final
- onErrorTone → int
-
Tone used for ColorScheme.onError from error FlexTonalPalette.
final
- onInverseSurfaceTone → int
-
Tone used for ColorScheme.onInverseSurface from neutral
FlexTonalPalette.
final
- onPrimaryContainerTone → int
-
Tone used for ColorScheme.onPrimaryContainer from primary
FlexTonalPalette.
final
- onPrimaryFixedTone → int
-
Tone used for ColorScheme.onPrimaryFixed from primary
FlexTonalPalette.
final
- onPrimaryFixedVariantTone → int
-
Tone used for ColorScheme.onPrimaryFixedVariant from primary
FlexTonalPalette.
final
- onPrimaryTone → int
-
Tone used for ColorScheme.onPrimary from primary FlexTonalPalette.
final
- onSecondaryContainerTone → int
-
Tone used for ColorScheme.onSecondaryContainer from secondary
FlexTonalPalette.
final
- onSecondaryFixedTone → int
-
Tone used for ColorScheme.secondaryFixed from secondary
FlexTonalPalette.
final
- onSecondaryFixedVariantTone → int
-
Tone used for ColorScheme.onSecondaryFixedVariant from secondary
FlexTonalPalette.
final
- onSecondaryTone → int
-
Tone used for ColorScheme.onSecondary from secondary FlexTonalPalette.
final
- onSurfaceTone → int
-
Tone used for ColorScheme.onSurface from neutral FlexTonalPalette.
final
- onSurfaceVariantTone → int
-
Tone used for ColorScheme.onSurfaceVariant from neutralVariant
FlexTonalPalette.
final
- onTertiaryContainerTone → int
-
Tone used for ColorScheme.onTertiaryContainer from tertiary
FlexTonalPalette.
final
- onTertiaryFixedTone → int
-
Tone used for ColorScheme.onTertiaryFixed from tertiary
FlexTonalPalette.
final
- onTertiaryFixedVariantTone → int
-
Tone used for ColorScheme.onTertiaryFixedVariant from tertiary
FlexTonalPalette.
final
- onTertiaryTone → int
-
Tone used for ColorScheme.onTertiary from tertiary FlexTonalPalette.
final
- outlineTone → int
-
Tone used for ColorScheme.outline from neutralVariant
FlexTonalPalette.
final
- outlineVariantTone → int
-
Tone used for ColorScheme.outlineVariant from neutralVariant
FlexTonalPalette.
final
- paletteType → FlexPaletteType
-
Defines what FlexPaletteType this FlexTones uses.
final
- primaryChroma → double?
-
Cam16 chroma value to use for primary colors FlexTonalPalette
generation.
final
- primaryContainerTone → int
-
Tone used for ColorScheme.primaryContainer from primary
FlexTonalPalette.
final
- primaryFixedDimTone → int
-
Tone used for ColorScheme.primaryFixedDim from primary
FlexTonalPalette.
final
- primaryFixedTone → int
-
Tone used for ColorScheme.primaryFixed from primary FlexTonalPalette.
final
- primaryMinChroma → double?
-
The minimum used chroma value.
final
- primaryTone → int
-
Tone used for ColorScheme.primary from primary FlexTonalPalette.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrimTone → int
-
Tone used for ColorScheme.scrim from neutral FlexTonalPalette.
final
- secondaryChroma → double?
-
Cam16 chroma value to use for secondary colors FlexTonalPalette
generation.
final
- secondaryContainerTone → int
-
Tone used for ColorScheme.secondaryContainer from secondary
FlexTonalPalette.
final
- secondaryFixedDimTone → int
-
Tone used for ColorScheme.secondaryFixedDim from secondary
FlexTonalPalette.
final
- secondaryFixedTone → int
-
Tone used for ColorScheme.secondaryFixed from secondary
FlexTonalPalette.
final
- secondaryMinChroma → double?
-
The minimum used chroma value.
final
- secondaryTone → int
-
Tone used for ColorScheme.secondary from secondary FlexTonalPalette.
final
- shadowTone → int
-
Tone used for ColorScheme.shadow from neutral FlexTonalPalette.
final
- surfaceBrightTone → int
-
Tone used for ColorScheme.surfaceBright from neutral FlexTonalPalette.
final
- surfaceContainerHighestTone → int
-
Tone used for ColorScheme.surfaceContainerHighest from neutral
FlexTonalPalette.
final
- surfaceContainerHighTone → int
-
Tone used for ColorScheme.surfaceContainerHigh from neutral
FlexTonalPalette.
final
- surfaceContainerLowestTone → int
-
Tone used for ColorScheme.surfaceContainerLowest from neutral
FlexTonalPalette.
final
- surfaceContainerLowTone → int
-
Tone used for ColorScheme.surfaceContainerLow from neutral
FlexTonalPalette.
final
- surfaceContainerTone → int
-
Tone used for ColorScheme.surfaceContainer from neutral
FlexTonalPalette.
final
- surfaceDimTone → int
-
Tone used for ColorScheme.surfaceDim from neutral FlexTonalPalette.
final
- surfaceTintTone → int
-
Tone used for ColorScheme.surfaceTint from primary FlexTonalPalette.
final
- surfaceTone → int
-
Tone used for ColorScheme.surface from neutral FlexTonalPalette.
final
- surfaceVariantTone → int?
-
Tone used for ColorScheme surfaceVariant from neutralVariant
FlexTonalPalette.
final
- tertiaryChroma → double?
-
Cam16 chroma value to use for tertiary colors FlexTonalPalette
generation.
final
- tertiaryContainerTone → int
-
Tone used for ColorScheme.tertiaryContainer from tertiary
FlexTonalPalette.
final
- tertiaryFixedDimTone → int
-
Tone used for ColorScheme.tertiaryFixedDim from tertiary
FlexTonalPalette.
final
- tertiaryFixedTone → int
-
Tone used for ColorScheme.tertiaryFixed from tertiary
FlexTonalPalette.
final
- tertiaryHueRotation → double?
-
The number of degrees to rotate Hue to use to get hue from primary
color's Hue, used as base with rotated amount of degrees provided.
final
- tertiaryMinChroma → double?
-
The minimum used chroma value.
final
- tertiaryTone → int
-
Tone used for ColorScheme.tertiary from tertiary FlexTonalPalette.
final
- useCam16 → bool
-
If true, the CAM16 color space is used to define the HCT color, if
false simpler and faster HCT from int is used.
final
Methods
-
copyWith(
{int? primaryTone, int? onPrimaryTone, int? primaryContainerTone, int? onPrimaryContainerTone, int? primaryFixedTone, int? primaryFixedDimTone, int? onPrimaryFixedTone, int? onPrimaryFixedVariantTone, int? secondaryTone, int? onSecondaryTone, int? secondaryContainerTone, int? onSecondaryContainerTone, int? secondaryFixedTone, int? secondaryFixedDimTone, int? onSecondaryFixedTone, int? onSecondaryFixedVariantTone, int? tertiaryTone, int? onTertiaryTone, int? tertiaryContainerTone, int? onTertiaryContainerTone, int? tertiaryFixedTone, int? tertiaryFixedDimTone, int? onTertiaryFixedTone, int? onTertiaryFixedVariantTone, int? errorTone, int? onErrorTone, int? errorContainerTone, int? onErrorContainerTone, int? surfaceTone, int? surfaceDimTone, int? surfaceBrightTone, int? surfaceContainerLowestTone, int? surfaceContainerLowTone, int? surfaceContainerTone, int? surfaceContainerHighTone, int? surfaceContainerHighestTone, int? onSurfaceTone, int? onSurfaceVariantTone, int? outlineTone, int? outlineVariantTone, int? shadowTone, int? scrimTone, int? inverseSurfaceTone, int? onInverseSurfaceTone, int? inversePrimaryTone, int? surfaceTintTone, int? backgroundTone, int? onBackgroundTone, int? surfaceVariantTone, double? primaryChroma, double? primaryMinChroma, double? secondaryChroma, double? secondaryMinChroma, double? tertiaryChroma, double? tertiaryMinChroma, double? tertiaryHueRotation, double? errorChroma, double? errorMinChroma, double? neutralChroma, double? neutralMinChroma, double? neutralVariantChroma, double? neutralVariantMinChroma, FlexPaletteType? paletteType}) → FlexTones - Copy the object with one or more provided properties changed.
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Flutter debug properties override, includes toString.
override
-
expressiveOnContainer(
[bool useExpressive = true]) → FlexTones - Returns a new FlexTones instance where the tones for light mode on container tones are set to 30 if they are 10. This gives us more color expressive container text and icons on none surface containers.
-
higherContrastFixed(
[bool useHigherContrast = true]) → FlexTones - Returns a new FlexTones instance where the tones for all fixed colors are modified.
-
monochromeSurfaces(
[bool useMonochrome = true]) → FlexTones - Returns a new FlexTones instance where the neutral and neutral variant chrome is set to 0. This will result in that regardless of the seed color the neutral and neutral variant tonal colors will be a pure grey scale without any chromacity in them. Resulting in surface colors with no color tint in them.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onMainsUseBW(
[bool useBW = true]) → FlexTones - Returns a new FlexTones instance where on colors tones for all main on color tones, are set to be either pure white 100 or black 0, depending what is appropriate contrast for its color pair.
-
onSurfacesUseBW(
[bool useBW = true]) → FlexTones - Returns a new FlexTones instance where on colors tones for all main on color tones, are set to be either pure white 100 or black 0, depending what is appropriate contrast for its color pair.
-
surfacesUseBW(
[bool useBW = true]) → FlexTones - Returns a new FlexTones instance where the tones for surface are set 0 (black) if it was <= 60 and to 100 (white) if > 60.
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringShort(
) → String -
A brief description of this object, usually just the runtimeType and the
hashCode.
inherited
Operators
-
operator ==(
Object other) → bool -
Override the equality operator.
override