OklabColor.fromList constructor

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

Constructs an OklabColor from a list of lab values.

lab must have exactly 3 or 4 values.

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

Implementation

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