Color class

Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of java.awt.Color in Java; it can also be trivially provided to UIColor's +colorWithRed:green:blue:alpha method in iOS; and, with just a little work, it can be easily formatted into a CSS rgba() string in JavaScript.

This reference page doesn't carry information about the absolute color space that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color space.

When color equality needs to be decided, implementations, unless documented otherwise, treat two colors as equal if all their red, green, blue, and alpha values each differ by at most 1e-5.

Annotations
  • @JsonSerializable()

Constructors

Color({required double red, required double green, required double blue, double? alpha})
Color.fromJson(Map<String, dynamic> json)
factory

Properties

alpha double?
The amount of alpha in the color as a value in the interval [0, 1].
final
blue double
The amount of blue in the color as a value in the interval [0, 1].
final
green double
The amount of green in the color as a value in the interval [0, 1].
final
hashCode int
The hash code for this object.
no setterinherited
red double
The amount of red in the color as a value in the interval [0, 1].
final
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
toJson() Map<String, dynamic>
toString() String
A string representation of this object.
override

Operators

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