LabColor.fromList constructor

LabColor.fromList(
  1. List<num> values
)

Constructs a LabColor from a list of LAB values.

values must have exactly 3 or 4 values.

The first value (L) must be >= 0 && <= 100.

The A and B values must be >= -128 && <= 127.

The alpha value, if provided, must be >= 0 && <= 255.

Implementation

factory LabColor.fromList(List<num> values) {
  assert(values.length == 3 || values.length == 4);
  assert(values[0] >= 0 && values[0] <= 100);
  assert(values[1] >= -128 && values[1] <= 127);
  assert(values[2] >= -128 && values[2] <= 127);
  if (values.length == 4) assert(values[3] >= 0 && values[3] <= 255);
  final alpha = values.length == 4 ? values[3].round() : 255;
  return LabColor(values[0], values[1], values[2], alpha);
}