defaultError property

FlexSchemeColor defaultError

Return a copy of this FlexSchemeColor that will when used, result in a theme that use the Material 3 Guide's default error and errorContainer colors.

The error and errorContainer colors are left out (null) when an instance is created. This results in a copy where the error colors are null, this again will result in that a theme created from the scheme will use the Material 3 design guide's default and standard error color. It deviates a bot from the Material 2 guide value and also includes defaults for the errorContainer values.

This function is useful if we want to create a dark scheme from a light scheme that already specifies the light scheme's error color, but we do not want a dark scheme where the light error colors are used by toDark to compute error colors for the dark scheme, instead we prefer to use use the Material default dark mode error color.

This is demonstrated in example 5) where the toDark method is used, but we do not want use the already defined built-in light schemes' error colors for the computed dark schemes' error colors.

Generally if you make your own schemes and are satisfied with the Material default error colors, you can omit defining them for the light scheme too. In that case it will remain null and get its default value, and likewise for the dark scheme. Example 5, the three custom schemes uses this setup.

If you in example 5 remove the defaultError before the toDark, you will notice that dark scheme's from the built-in schemes get a dark scheme where the error color changes when you use the "Compute dark theme" feature and the white blend "level" slider. Whereas, the custom example schemes that had no error color specified for their light scheme, still get the fixed default dark error color, as when we used this defaultError feature.

Implementation

FlexSchemeColor get defaultError {
  return FlexSchemeColor(
    primary: primary,
    primaryContainer: primaryContainer,
    secondary: secondary,
    secondaryContainer: secondaryContainer,
    tertiary: tertiary,
    tertiaryContainer: tertiaryContainer,
    appBarColor: appBarColor,
    swapOnMaterial3: swapOnMaterial3,
  );
}