Gradient.linearColors constructor
Creates an evenly distributed linear gradient from colors.
Implementation
factory Gradient.linearColors(num angle, List<Object> colors) {
if (colors.isEmpty) {
throw ArgumentError.value(colors, 'colors', 'Must not be empty.');
}
final lastIndex = colors.length - 1;
final stops = [
for (var index = 0; index < colors.length; index++)
GradientStop(
colors[index],
lastIndex == 0 ? 0 : (index / lastIndex) * 100,
),
];
return Gradient.linear(angle, stops);
}