onSurfacesUseBW method

FlexTones onSurfacesUseBW([
  1. bool useBW = true
])

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.

This will make the seeded on colors for onBackground, onSurface, onSurfaceVariant, and onInverseSurface pure black or white, depending on need contrast, instead of tinted black and white.

This is a modifier, using copyWith, that can be used to change any existing or pre-made FlexTones config to not have any color tint in their seeded main on colors.

The useBW flag is true by default, making the function effective. If set to false, the function is a no op and just returns the FlexTones object unmodified. This is typically used to control applying the tint removal via a controller.

Implementation

FlexTones onSurfacesUseBW([bool useBW = true]) {
  // ignore: avoid_returning_this
  if (!useBW) return this;
  return copyWith(
    onBackgroundTone: backgroundTone <= 60 ? 100 : 0,
    onSurfaceTone: surfaceTone <= 60 ? 100 : 0,
    onSurfaceVariantTone: surfaceVariantTone <= 60 ? 100 : 0,
    onInverseSurfaceTone: inverseSurfaceTone <= 60 ? 100 : 0,
  );
}