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 FlexTones.vivid, but with more colors in surfaces.
-
FlexTones.vividBackground, like FlexTones.vividSurfaces, but with slightly modified background color tone mappings.
-
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, 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, 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, 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
adjusted chroma on neutrals and more color tinted surfaces and onColors.
factory
Properties
- errorChroma → double?
-
Cam16 chroma value to use for error colors FlexTonalPalette
generation.
final
- errorContainerTone → int
-
Tone used for
ColorScheme.errorContainerfrom error FlexTonalPalette.final - errorMinChroma → double?
-
The minimum used error chroma value.
final
- errorTone → int
-
Tone used for
ColorScheme.errorfrom error FlexTonalPalette.final - hashCode → int
-
Override for hashcode, dart.ui Jenkins based.
no setteroverride
- inversePrimaryTone → int
-
Tone used for
ColorScheme.inversePrimaryfrom primary FlexTonalPalette.final - inverseSurfaceTone → int
-
Tone used for
ColorScheme.inverseSurfacefrom 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 variant colors FlexTonalPalette
generation.
final
- neutralVariantMinChroma → double?
-
The minimum used neutral variant chroma value.
final
- onErrorContainerTone → int
-
Tone used for
ColorScheme.onErrorContainerfrom error FlexTonalPalette.final - onErrorTone → int
-
Tone used for
ColorScheme.onErrorfrom error FlexTonalPalette.final - onInverseSurfaceTone → int
-
Tone used for
ColorScheme.onInverseSurfacefrom neutral FlexTonalPalette.final - onPrimaryContainerTone → int
-
Tone used for
ColorScheme.onPrimaryContainerfrom primary FlexTonalPalette.final - onPrimaryFixedTone → int
-
Tone used for
ColorScheme.onPrimaryFixedfrom primary FlexTonalPalette.final - onPrimaryFixedVariantTone → int
-
Tone used for
ColorScheme.onPrimaryFixedVariantfrom primary FlexTonalPalette.final - onPrimaryTone → int
-
Tone used for
ColorScheme.onPrimaryfrom primary FlexTonalPalette.final - onSecondaryContainerTone → int
-
Tone used for
ColorScheme.onSecondaryContainerfrom secondary FlexTonalPalette.final - onSecondaryFixedTone → int
-
Tone used for
ColorScheme.onSecondaryFixedfrom secondary FlexTonalPalette.final - onSecondaryFixedVariantTone → int
-
Tone used for
ColorScheme.onSecondaryFixedVariantfrom secondary FlexTonalPalette.final - onSecondaryTone → int
-
Tone used for
ColorScheme.onSecondaryfrom secondary FlexTonalPalette.final - onSurfaceTone → int
-
Tone used for
ColorScheme.onSurfacefrom neutral FlexTonalPalette.final - onSurfaceVariantTone → int
-
Tone used for
ColorScheme.onSurfaceVariantfrom neutralVariant FlexTonalPalette.final - onTertiaryContainerTone → int
-
Tone used for
ColorScheme.onTertiaryContainerfrom tertiary FlexTonalPalette.final - onTertiaryFixedTone → int
-
Tone used for
ColorScheme.onTertiaryFixedfrom tertiary FlexTonalPalette.final - onTertiaryFixedVariantTone → int
-
Tone used for
ColorScheme.onTertiaryFixedVariantfrom tertiary FlexTonalPalette.final - onTertiaryTone → int
-
Tone used for
ColorScheme.onTertiaryfrom tertiary FlexTonalPalette.final - outlineTone → int
-
Tone used for
ColorScheme.outlinefrom neutralVariant FlexTonalPalette.final - outlineVariantTone → int
-
Tone used for
ColorScheme.outlineVariantfrom 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.primaryContainerfrom primary FlexTonalPalette.final - primaryFixedDimTone → int
-
Tone used for
ColorScheme.primaryFixedDimfrom primary FlexTonalPalette.final - primaryFixedTone → int
-
Tone used for
ColorScheme.primaryFixedfrom primary FlexTonalPalette.final - primaryMinChroma → double?
-
The minimum used chroma value.
final
- primaryTone → int
-
Tone used for
ColorScheme.primaryfrom primary FlexTonalPalette.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrimTone → int
-
Tone used for
ColorScheme.scrimfrom neutral FlexTonalPalette.final - secondaryChroma → double?
-
Cam16 chroma value to use for secondary colors FlexTonalPalette
generation.
final
- secondaryContainerTone → int
-
Tone used for
ColorScheme.secondaryContainerfrom secondary FlexTonalPalette.final - secondaryFixedDimTone → int
-
Tone used for
ColorScheme.secondaryFixedDimfrom secondary FlexTonalPalette.final - secondaryFixedTone → int
-
Tone used for
ColorScheme.secondaryFixedfrom secondary FlexTonalPalette.final - secondaryMinChroma → double?
-
The minimum used chroma value.
final
- secondaryTone → int
-
Tone used for
ColorScheme.secondaryfrom secondary FlexTonalPalette.final - shadowTone → int
-
Tone used for
ColorScheme.shadowfrom neutral FlexTonalPalette.final - surfaceBrightTone → int
-
Tone used for
ColorScheme.surfaceBrightfrom neutral FlexTonalPalette.final - surfaceContainerHighestTone → int
-
Tone used for
ColorScheme.surfaceContainerHighestfrom neutral FlexTonalPalette.final - surfaceContainerHighTone → int
-
Tone used for
ColorScheme.surfaceContainerHighfrom neutral FlexTonalPalette.final - surfaceContainerLowestTone → int
-
Tone used for
ColorScheme.surfaceContainerLowestfrom neutral FlexTonalPalette.final - surfaceContainerLowTone → int
-
Tone used for
ColorScheme.surfaceContainerLowfrom neutral FlexTonalPalette.final - surfaceContainerTone → int
-
Tone used for
ColorScheme.surfaceContainerfrom neutral FlexTonalPalette.final - surfaceDimTone → int
-
Tone used for
ColorScheme.surfaceDimfrom neutral FlexTonalPalette.final - surfaceTintTone → int
-
Tone used for
ColorScheme.surfaceTintfrom primary FlexTonalPalette.final - surfaceTone → int
-
Tone used for
ColorScheme.surfacefrom neutral FlexTonalPalette.final - tertiaryChroma → double?
-
Cam16 chroma value to use for tertiary colors FlexTonalPalette
generation.
final
- tertiaryContainerTone → int
-
Tone used for
ColorScheme.tertiaryContainerfrom tertiary FlexTonalPalette.final - tertiaryFixedDimTone → int
-
Tone used for
ColorScheme.tertiaryFixedDimfrom tertiary FlexTonalPalette.final - tertiaryFixedTone → int
-
Tone used for
ColorScheme.tertiaryFixedfrom 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.tertiaryfrom 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, 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, bool? useCam16}) → 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 non-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 chroma 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 the tones for the surface on colors 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