Color class
Represents a color.
This class is based into dart:ui
(Flutter) implementation.
Constructors
- Color(int value)
-
Construct a color from the lower 32 bits of an int.
const
- Color.fromARGB(int a, int r, int g, int b)
-
Construct a color from the lower 8 bits of four integers.
const
- Color.fromHex(String hexColor)
-
factory
- Color.fromRGBO(int r, int g, int b, [double opacity = 1.0])
-
Create a color from red, green, blue, and opacity, similar to
rgba()
in CSS.const - Color.parse(String? colorStr)
-
factory
Properties
- alpha → int
-
The alpha channel of this color in an 8 bit value.
no setter
- alphaRatio → double
-
Returns alpha in range of 0 .. 1 value.
no setter
- blue → int
-
The blue channel of this color in an 8 bit value.
no setter
- green → int
-
The green channel of this color in an 8 bit value.
no setter
- hasAlpha → bool
-
Returns
true
if colors has alpha != 255 value.no setter - hashCode → int
-
The hash code for this object.
no setteroverride
- opacity → double
-
The alpha channel of this color as a double.
no setter
- red → int
-
The red channel of this color in an 8 bit value.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → int
-
A 32 bit value representing this color.
final
Methods
-
computeLuminance(
) → double - Returns a brightness value between 0 for darkest and 1 for lightest.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toHex(
) → String -
toString(
) → String -
A string representation of this object.
override
-
withAlpha(
int a) → Color -
Returns a new color that matches this color with the alpha channel
replaced with
a
(which ranges from 0 to 255). -
withAlphaRatio(
double aRatio) → Color -
Returns a new color with alpha value
aRatio
* 255. -
withBlue(
int b) → Color -
Returns a new color that matches this color with the blue channel replaced
with
b
(which ranges from 0 to 255). -
withGreen(
int g) → Color -
Returns a new color that matches this color with the green channel
replaced with
g
(which ranges from 0 to 255). -
withOpacity(
double opacity) → Color -
Returns a new color that matches this color with the alpha channel
replaced with the given
opacity
(which ranges from 0.0 to 1.0). -
withRed(
int r) → Color -
Returns a new color that matches this color with the red channel replaced
with
r
(which ranges from 0 to 255).
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Properties
Static Methods
-
alphaBlend(
Color foreground, Color background) → Color - Combine the foreground color as a transparent color over top of a background color, and return the resulting combined color.
-
getAlphaFromOpacity(
double opacity) → int -
Returns an alpha value representative of the provided
opacity
value.