ColorUtils class

Helper class for color operations.

Constructors

ColorUtils()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

basicColorsFromHex(String hex) Map<String, int>
Fetches the basic color int values for red, green, blue from the given hex string.
calculateRelativeLuminance(int red, int green, int blue, {int decimals = 2}) double
Calculates the relative luminance for the given red, green, blue values.
contrastColor(String hex) String
Calculates the limunance for the given hex color and returns black as hex for bright colors, white as hex for dark colors.
fillUpHex(String hex) String
Fills up the given 3 char hex string to 6 char hex string.
hexToInt(String hex) int
Converts the given hex color string to the corresponding int.
intToHex(int i) String
Converts the given integer i to a hex string with a leading #.
invertColor(String color) String
Inverts Color Hex code Convert string to (4-bit int) and apply bitwise-NOT operation then convert back to Hex String e.g: convert white (FFFFFF) to Dark (000000). Returns Inverted String Color.
isDark(String hex) bool
Returns true or false if the calculated relative luminance from the given hex is less than 0.5.
shadeColor(String hex, double percent) String
Lightens or darkens the given hex color by the given percent.
swatchColor(String hex, {double percentage = 15, int amount = 5}) List<String>
Swatch the given hex color.

Constants

BASIC_COLOR_BLUE → const String
BASIC_COLOR_GREEN → const String
BASIC_COLOR_RED → const String
HEX_BLACK → const String
HEX_WHITE → const String