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.
- 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. This FlexTones the paletteType extended via FlexPaletteType.extended, for additional tone fidelity.
- 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. This FlexTones the paletteType extended via FlexPaletteType.extended, for additional tone fidelity.
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 secondaryTone, required int onSecondaryTone, required int secondaryContainerTone, required int onSecondaryContainerTone, required int tertiaryTone, required int onTertiaryTone, required int tertiaryContainerTone, required int onTertiaryContainerTone, required int errorTone, required int onErrorTone, required int errorContainerTone, required int onErrorContainerTone, required int backgroundTone, required int onBackgroundTone, required int surfaceTone, required int onSurfaceTone, required int surfaceVariantTone, 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.common})
-
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 results in a high contrast colorful
theme with background and surface tone 98, in light mode and very low
chroma in neutrals light mode (2 and 4) and moderate in dark mode
(3 and 6). Dark mode uses dark surface and background tone 6.
factory
- FlexTones.dark({int primaryTone = 80, int onPrimaryTone = 20, int primaryContainerTone = 30, int onPrimaryContainerTone = 90, int secondaryTone = 80, int onSecondaryTone = 20, int secondaryContainerTone = 30, int onSecondaryContainerTone = 90, int tertiaryTone = 80, int onTertiaryTone = 20, int tertiaryContainerTone = 30, int onTertiaryContainerTone = 90, int errorTone = 80, int onErrorTone = 20, int errorContainerTone = 30, int onErrorContainerTone = 80, int backgroundTone = 10, int onBackgroundTone = 90, int surfaceTone = 10, int onSurfaceTone = 90, int surfaceVariantTone = 30, int onSurfaceVariantTone = 80, int outlineTone = 60, int outlineVariantTone = 30, int shadowTone = 0, int scrimTone = 0, int inverseSurfaceTone = 90, int onInverseSurfaceTone = 20, int inversePrimaryTone = 40, int surfaceTintTone = 80, double? primaryChroma, double? primaryMinChroma, double? secondaryChroma, double? secondaryMinChroma, double? tertiaryChroma, double? tertiaryMinChroma, double? tertiaryHueRotation, double? errorChroma, double? errorMinChroma, double? neutralChroma = 4, double? neutralMinChroma, double? neutralVariantChroma = 8, double? neutralVariantMinChroma, FlexPaletteType paletteType = FlexPaletteType.common})
-
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 secondaryTone = 40, int onSecondaryTone = 100, int secondaryContainerTone = 90, int onSecondaryContainerTone = 10, int tertiaryTone = 40, int onTertiaryTone = 100, int tertiaryContainerTone = 90, int onTertiaryContainerTone = 10, int errorTone = 40, int onErrorTone = 100, int errorContainerTone = 90, int onErrorContainerTone = 10, int backgroundTone = 99, int onBackgroundTone = 10, int surfaceTone = 99, int onSurfaceTone = 10, int surfaceVariantTone = 90, int onSurfaceVariantTone = 30, int outlineTone = 50, int outlineVariantTone = 80, int shadowTone = 0, int scrimTone = 0, int inverseSurfaceTone = 20, int onInverseSurfaceTone = 95, int inversePrimaryTone = 80, int surfaceTintTone = 40, double? primaryChroma, double? primaryMinChroma, double? secondaryChroma, double? secondaryMinChroma, double? tertiaryChroma, double? tertiaryMinChroma, double? tertiaryHueRotation, double? errorChroma, double? errorMinChroma, double? neutralChroma = 4, double? neutralMinChroma, double? neutralVariantChroma = 8, double? neutralVariantMinChroma, FlexPaletteType paletteType = FlexPaletteType.common})
-
Create an M3 standard light tonal palette tones extraction setup.
const
- FlexTones.material(Brightness brightness)
-
Create a M3 standard tonal palette tones extraction and CAM16
chroma setup.
factory
- FlexTones.oneHue(Brightness brightness)
-
Create a M3 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
tone mapping surface and background are swapped.
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
double 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
- onPrimaryTone → int
-
Tone used for ColorScheme.onPrimary from primary FlexTonalPalette.
final
- onSecondaryContainerTone → int
-
Tone used for ColorScheme.onSecondaryContainer 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
- 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
- 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
- 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
- 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
- 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
Methods
-
copyWith(
{int? primaryTone, int? onPrimaryTone, int? primaryContainerTone, int? onPrimaryContainerTone, int? secondaryTone, int? onSecondaryTone, int? secondaryContainerTone, int? onSecondaryContainerTone, int? tertiaryTone, int? onTertiaryTone, int? tertiaryContainerTone, int? onTertiaryContainerTone, int? errorTone, int? onErrorTone, int? errorContainerTone, int? onErrorContainerTone, int? backgroundTone, int? onBackgroundTone, int? surfaceTone, int? onSurfaceTone, int? surfaceVariantTone, 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}) → FlexTones - Copy the object with one or more provided properties changed.
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Flutter debug properties override, includes toString.
override
-
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 and background 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