schemeColorPair static method
Returns the Color from passed in ColorScheme in colorScheme
that is the color pair corresponding to the SchemeColor enum
value passed in via value
.
This function is used to get the color value for the color pair to the passed in scheme enum value, thus giving the correct Colorscheme based contrast color for the provided SchemeColor. For example passing in SchemeColor.primary enum value, will return the ColorScheme.onPrimary. Wise versa, passing in SchemeColor.onPrimary will return the color ColorScheme.primary.
Implementation
static Color schemeColorPair(SchemeColor value, ColorScheme colorScheme) {
switch (value) {
case SchemeColor.primary:
return colorScheme.onPrimary;
case SchemeColor.onPrimary:
return colorScheme.primary;
// There is no onColor pair for primaryVariant, we return onPrimary,
// this issue will go away when primaryVariant is deprecated and
// replaced with new container color that has a defined onColor pair.
case SchemeColor.primaryVariant:
return colorScheme.onPrimary;
case SchemeColor.secondary:
return colorScheme.onSecondary;
case SchemeColor.onSecondary:
return colorScheme.secondary;
// There is no onColor pair for secondaryVariant, we return onSecondary,
// this issue will go away when secondaryVariant is deprecated and
// replaced with new container color that has a defined onColor pair.
case SchemeColor.secondaryVariant:
return colorScheme.onSecondary;
case SchemeColor.surface:
return colorScheme.onSurface;
case SchemeColor.onSurface:
return colorScheme.surface;
case SchemeColor.background:
return colorScheme.onBackground;
case SchemeColor.onBackground:
return colorScheme.background;
case SchemeColor.error:
return colorScheme.onError;
case SchemeColor.onError:
return colorScheme.error;
}
}