setFill method

void setFill({
  1. Color? color,
  2. List<Color>? colors,
  3. bool family = true,
})

Implementation

void setFill({Color? color, List<Color>? colors, bool family = true}) {
  // if both color and colors are set, append color to colors list
  colors = [if (colors != null) ...colors, if (color != null) color];

  if (family) {
    for (var mob in getVectorizedFamily()) {
      mob.setFill(colors: colors, family: false);
    }
  }

  if (colors.isNotEmpty) {
    fillColors ??= colors;

    if (fillColors!.length < colors.length) {
      fillColors = stretchListToLength(fillColors!, colors.length);
    } else if (colors.length < fillColors!.length) {
      fillColors = stretchListToLength(colors, fillColors!.length);
    }

    fillColors = [for (var i in range(end: fillColors!.length)) colors[i]];
  }
}