buildOffset method

List<int> buildOffset(
  1. List<int> colors,
  2. int offset
)

It takes a list of colors and an offset, and returns a new list of colors with the offset applied

Args: colors (List): A list of colors to be used in the gradient. offset (int): The offset of the color list.

Returns: A new list of colors that is offset by the offset parameter.

Implementation

List<int> buildOffset(List<int> colors, int offset) {
  final int i = offset % colors.length;
  final List<int> newColors = colors.sublist(i)..addAll(colors.sublist(0, i));

  return newColors;
}