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? onInverseSurface, required Color onBackground, required Color onError, Color? onErrorContainer})
Default constructor. In most situations the factory FlexSchemeOnColors.from is the preferred way to create the onColors.
const
FlexSchemeOnColors.from({required Color primary, Color? primaryContainer, required Color secondary, Color? secondaryContainer, Color? tertiary, Color? tertiaryContainer, required Color surface, Color? surfaceVariant, Color? inverseSurface, required Color background, required Color error, Color? errorContainer, Color? onPrimary, Color? onPrimaryContainer, Color? onSecondary, Color? onSecondaryContainer, Color? onTertiary, Color? onTertiaryContainer, Color? onSurface, Color? onSurfaceVariant, Color? onInverseSurface, Color? onBackground, 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 surfaceVariantAlpha = 0, int inverseSurfaceAlpha = 0, int backgroundAlpha = 0, int errorAlpha = 0, int errorContainerAlpha = 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
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? onInverseSurface, Color? onBackground, Color? onError, Color? onErrorContainer}) 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.