onMainsUseBW method
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 onPrimary
, onPrimaryContainer
,
onSecondary
, onSecondaryContainer
, onTertiary
,
onTertiaryContainer
, onError
and onErrorContainer
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 onMainsUseBW([bool useBW = true]) {
// ignore: avoid_returning_this
if (!useBW) return this;
return copyWith(
onPrimaryTone: primaryTone <= 60 ? 100 : 0,
onPrimaryContainerTone: primaryContainerTone <= 60 ? 100 : 0,
onSecondaryTone: secondaryTone <= 60 ? 100 : 0,
onSecondaryContainerTone: secondaryContainerTone <= 60 ? 100 : 0,
onTertiaryTone: tertiaryTone <= 60 ? 100 : 0,
onTertiaryContainerTone: tertiaryContainerTone <= 60 ? 100 : 0,
onErrorTone: errorTone <= 60 ? 100 : 0,
onErrorContainerTone: errorContainerTone <= 60 ? 100 : 0,
);
}