FlexSchemeOnColors class
Immutable data class used to create "on" colors for displaying text and icons on surface, background, error colors and the primary, secondary and tertiary colors.
Normally the on colors are not provided manually, but computed by using the FlexSchemeOnColors.from static function that uses the ThemeData.estimateBrightnessForColor static function for each on color and returns a FlexSchemeOnColors object with the appropriate colors.
In Material 2 design used in Flutter before version 2.10, the primaryVariant and SecondaryVariant did not have their own onColor. This was a limitation imposed by the Flutter SDK ColorScheme class and ThemeData using it. It was assumed that the onColor for primary and secondary colors will also work OK for their variants. This was usually correct if the variant colors wre close in brightness to their none variant versions. In Material 3 design, with updated ColorScheme in Flutter starting with version 2.10, all main colors have their own onColor. Thus in FlexColorScheme version 5.0.0 and later this challenge no longer exists.
Scaffold and dialog background colors that FlexColorScheme allows us to define separately, do not have their own "on" color, it is assumed that they are close in brightness to the background color, so they uses the same on color as background.
- Mixed-in types
- Annotations
Constructors
- FlexSchemeOnColors({required Color onPrimary, Color? onPrimaryContainer, required Color onSecondary, Color? onSecondaryContainer, Color? onTertiary, Color? onTertiaryContainer, required Color onSurface, Color? onSurfaceVariant, Color? onSurfaceDim, Color? onSurfaceBright, Color? onSurfaceContainerLowest, Color? onSurfaceContainerLow, Color? onSurfaceContainer, Color? onSurfaceContainerHighest, Color? onSurfaceContainerHigh, Color? onInverseSurface, required Color onError, Color? onErrorContainer, @Deprecated('This color was deprecated in FCS 8.0 because Flutter 3.22 ' 'deprecated the color. ' 'It no longer has any function in FCS v8 and will be removed in v9.') Color? onBackground})
-
Default constructor. In most situations the factory
FlexSchemeOnColors.from is the preferred way to create the onColors.
const
- FlexSchemeOnColors.from({bool? useMaterial3, required Color primary, Color? primaryContainer, required Color secondary, Color? secondaryContainer, Color? tertiary, Color? tertiaryContainer, required Color surface, Color? inverseSurface, Color? surfaceTint, required Color error, Color? errorContainer, Color? onPrimary, Color? onPrimaryContainer, Color? onSecondary, Color? onSecondaryContainer, Color? onTertiary, Color? onTertiaryContainer, Color? onSurface, Color? onSurfaceVariant, Color? onInverseSurface, Color? onError, Color? onErrorContainer, int primaryAlpha = 0, int primaryContainerAlpha = 0, int secondaryAlpha = 0, int secondaryContainerAlpha = 0, int tertiaryAlpha = 0, int tertiaryContainerAlpha = 0, int surfaceAlpha = 0, int inverseSurfaceAlpha = 0, int errorAlpha = 0, int errorContainerAlpha = 0, @Deprecated('This color was deprecated in FCS 8.0 because Flutter 3.22 ' 'deprecated the color. ' 'It no longer has any function in FCS v8 and will be removed in v9.') Color? background, @Deprecated('This color was deprecated in FCS 8.0 because Flutter 3.22 ' 'deprecated the color. ' 'It no longer has any function in FCS v8 and will be removed in v9.') Color? onBackground, @Deprecated('This property was deprecated in FCS 8.0 because Flutter 3.22 ' 'deprecated the related color. ' 'It no longer has any function in FCS v8 and will be removed in v9.') int backgroundAlpha = 0, @Deprecated('This color was deprecated in FCS 8.0 because Flutter 3.22 ' 'deprecated the color. ' 'It no longer has any function in FCS v8 and will be removed in v9.') Color? surfaceVariant, @Deprecated('This property was deprecated in FCS 8.0 because Flutter 3.22 ' 'deprecated the related color. ' 'It no longer has any function in FCS v8 and will be removed in v9.') int surfaceVariantAlpha = 0})
-
Compute on colors for required primary, secondary, surface, background
and error colors and returns a valid FlexSchemeOnColors with correct on
colors for these colors.
factory
Properties
- hashCode → int
-
Override for hashcode. Using Darts object hash.
no setteroverride
- onBackground → Color?
-
A color that is clearly legible when drawn on background color also used
as on color for scaffold background color.
final
- onError → Color
-
A color that is clearly legible when drawn on error color.
final
- onErrorContainer → Color?
-
A color that is clearly legible when drawn on error container color.
final
- onInverseSurface → Color?
-
A color that is clearly legible when drawn on inverseSurface color.
final
- onPrimary → Color
-
A color that is clearly legible when drawn on primary color.
final
- onPrimaryContainer → Color?
-
A color that is clearly legible when drawn on primaryContainer color.
final
- onSecondary → Color
-
A color that is clearly legible when drawn on secondary color.
final
- onSecondaryContainer → Color?
-
A color that is clearly legible when drawn on secondaryContainer color.
final
- onSurface → Color
-
A color that is clearly legible when drawn on surface color.
final
- onSurfaceBright → Color?
-
A color that is clearly legible when drawn on surfaceBright color.
final
- onSurfaceContainer → Color?
-
A color that is clearly legible when drawn on surfaceContainer color.
final
- onSurfaceContainerHigh → Color?
-
A color that is clearly legible when drawn on surfaceContainerHigh color.
final
- onSurfaceContainerHighest → Color?
-
A color that is clearly legible when drawn on surfaceContainerHighest
color.
final
- onSurfaceContainerLow → Color?
-
A color that is clearly legible when drawn on surfaceContainerLow color.
final
- onSurfaceContainerLowest → Color?
-
A color that is clearly legible when drawn on surfaceContainerLowest
color.
final
- onSurfaceDim → Color?
-
A color that is clearly legible when drawn on surfaceDim color.
final
- onSurfaceVariant → Color?
-
A color that is clearly legible when drawn on surfaceVariant color.
final
- onTertiary → Color?
-
A color that is clearly legible when drawn on tertiary color.
final
- onTertiaryContainer → Color?
-
A color that is clearly legible when drawn on tertiaryContainer color.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
copyWith(
{Color? onPrimary, Color? onPrimaryContainer, Color? onSecondary, Color? onSecondaryContainer, Color? onTertiary, Color? onTertiaryContainer, Color? onSurface, Color? onSurfaceVariant, Color? onSurfaceDim, Color? onSurfaceBright, Color? onSurfaceContainerLowest, Color? onSurfaceContainerLow, Color? onSurfaceContainer, Color? onSurfaceContainerHigh, Color? onSurfaceContainerHighest, Color? onInverseSurface, Color? onError, Color? onErrorContainer, Color? onBackground}) → FlexSchemeOnColors - 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
-
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
Static Methods
-
estimateErrorBrightness(
Color color) → Brightness - Brightness estimation for error colors that includes fix to consider M2 spec for on M2 dark error color.