Color class

An immutable 32-bit color value in ARGB format.

This class is intended to be semantically similar to dart:ui's Color, but includes additional functionality, and is platform independent (i.e. is suitable for non-Flutter environments, such as CLIs or non-Flutter web applications).

NOTE: Unlike dart:ui, custom implementations are not supported. Prefer composition over inheritance.

Annotations
  • @immutable
  • @sealed

Constructors

Color(int value)
Constructs 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 4 integers.
const
Color.fromHSB(double h, double s, double v, {double opacity = 1.0})
Constructs a color from _Hue-Saturation-Brightness, an RGB alternative.
factory
Color.fromHSL(double h, double s, double l, {double opacity = 1.0})
Constructs a color from Hue-Saturation-Lightness, an RGB alternative.
factory
Color.fromRGB(int r, int g, int b)
Constructs a fully opaque color from the lower 8-bits of 3 integers.
const
Color.fromRGBO(int r, int g, int b, double o)
Construct a color from the lower 8-bits of 3 integers and a double.
const

Properties

alpha int
The alpha channel of this color as an 8-bit value.
no setter
blue int
The blue channel of this color as an 8-bit value.
no setter
green int
The green channel of this color as an 8-bit value.
no setter
hashCode int
The hash code for this object.
no setteroverride
isOpaque bool
Whether the color is fully opaque, i.e. alpha == 0xFF.
no setter
isTransparent bool
Whether the color is not fully opaque, i.e. alpha < 0xFF.
no setter
isVisible bool
Whether the color is not fully transparent, i.e. alpha > 0x00.
no setter
opacity double
The alpha channel of this color as a double.
no setter
red int
The red channel of this color as 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

computeHSB() → HSBResult
Computes and returns as hue, saturation, and brightness.
computeHSL() → HSLResult
Computes and returns as hue, saturation, and lightness.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override
withARGB({int? alpha, int? red, int? green, int? blue}) Color
Returns a copy of color element, with non-null values replaced.
withRGBO({int? red, int? green, int? blue, double? opacity}) Color
Returns a copy of color element, with non-null values replaced.

Operators

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