SassColor.forSpace constructor

SassColor.forSpace(
  1. ColorSpace space,
  2. List<double?> channels, [
  3. double? alpha = 1
])

Creates a color in the color space named space.

If null is passed for alpha, that indicates that it's a missing component. In most cases, this is equivalent to the color being transparent.

Throws a RangeError if alpha isn't between 0 and 1 or if channels is the wrong length for space.

Implementation

factory SassColor.forSpace(ColorSpace space, List<double?> channels,
        [double? alpha = 1]) =>
    channels.length == space.channels.length
        ? SassColor.forSpaceInternal(
            space, channels[0], channels[1], channels[2], alpha)
        : throw RangeError.value(channels.length, "channels.length",
            'must be exactly ${space.channels.length} for color space "$space"');