Color class

A color utility class.

Provides conversion between different color representations.

Constructors

Color.fromHex(String hex)
Deprecated; use parse instead.
factory
Color.fromRgb(int r, int g, int b)
Deprecated; use rgb instead.
Color.fromRgbString(String rgb)
Deprecated; use parse instead.
factory
Color.rgb(int r, int g, int b)
RGB color.
const
Color.rgba(int red, int green, int blue, num alpha)
RGB color with an alpha channel.
const

Properties

alpha num
Alpha channel.
final
blue int
Color channels.
final
green int
Color channels.
final
hashCode int
The hash code for this object.
no setteroverride
hexString String
Returns this as a string in #rrggbb or #rrggbbaa hex notation.
no setter
red int
Color channels.
final
rgbString String
Returns this as a string in rgb() or rgba() functional notation.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

contrastRatio(Color background) num
The contrast ratio against a background color, as specified by https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef.
distanceFrom(Color other) int
Calculates the square of the Euclidean distance from another color.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override
withAlpha(num a) Color
Creates a copy with the given alpha channel value.
withBackground(Color background) Color
Resolves against a background color.

Operators

operator ==(Object o) bool
The equality operator.
override

Static Methods

lerp(Color? a, Color? b, num t) Color?
Linearly interpolates between two colors.
parse(String s) Color
Parses a string into a Color.