toGradientStops method

List<GradientStop> toGradientStops()

Creates evenly-spaced gradient stops from this color list.

Implementation

List<GradientStop> toGradientStops() {
  if (isEmpty) return [];
  if (length == 1) return [GradientStop(0.5, first)];

  return List.generate(length, (i) {
    return GradientStop(i / (length - 1), this[i]);
  });
}