changeColorAt method

  1. @override
SweepColorGradient changeColorAt(
  1. int index,
  2. ColorDerivative color
)
override

Changes the color at the specified index.

Parameters:

  • index: The zero-based index of the color stop to modify.
  • color: The new color for the stop.

Returns: A new ColorGradient with the updated color.

Implementation

@override
SweepColorGradient changeColorAt(int index, ColorDerivative color) {
  List<ColorStop> newColors = List.from(colors);
  newColors[index] = ColorStop(
    color: color,
    position: newColors[index].position,
  );
  return copyWith(colors: newColors);
}