FlexColorExtensions extension
Extensions on Color to brighten, lighten, darken and blend colors and can get a shade for gradients.
Some of the extensions are rewrites of TinyColor's functions https://pub.dev/packages/tinycolor. The TinyColor algorithms have also been modified to use Flutter's HSLColor class instead of the custom one in the TinyColor lib. The functions from TinyColor reimplemented as Color extensions here are, brighten, lighten and darken. They are used for color calculations in FlexColorScheme but also exposed for reuse.
Another frequently used extension is the one used to blend two colors using alpha value. This extension is used to calculate branded surface colors used by FlexColorScheme's branded surfaces and for automatic dark color schemes from a light scheme.
The getShadeColor extension is less frequently used and when used, typically used to color makes colors shades for gradient AppBars, with default setting to not change black and white.
The color extension also include getting a color's RGB hex code as a string in two different formats. Extension hexCode returns a Flutter style HEX code string of a Color value, meaning it starts with 0x and alpha value before the RGB Hex values. The plain hex extension returns a typical API formatted hex color string starting with # and no alpha value.
- on
Properties
Methods
-
blend(
Color input, [int amount = 10]) → Color - Blend in the given input Color with a percentage of alpha.
-
brighten(
[int amount = 10]) → Color - Brightens the color with the given integer percentage amount. Defaults to 10%.
-
darken(
[int amount = 10]) → Color - Darkens the color with the given integer percentage amount. Defaults to 10%.
-
getShadeColor(
{int shadeValue = 15, bool lighten = true, bool keepBlack = true, bool keepWhite = true}) → Color -
The getShadeColor extension is used to make a color darker or lighter,
the
shadeValue
defines the amount in % that the shade should be changed. -
lighten(
[int amount = 10]) → Color - Lightens the color with the given integer percentage amount. Defaults to 10%.