withColors method

ProgressModel withColors(
  1. List<String> colors
)

Returns a copy of the model with the given colors.

  • 0 colors: resets to default full color.
  • 1 color: uses a solid fill with the given color.
  • 2+ colors: uses a blend of the provided colors.

Implementation

ProgressModel withColors(List<String> colors) {
  if (colors.isEmpty) {
    return copyWith(fullColor: '#7571F9', blend: [], colorFunc: null);
  }
  if (colors.length == 1) {
    return copyWith(fullColor: colors[0], blend: [], colorFunc: null);
  }
  return copyWith(blend: colors, colorFunc: null);
}