spread method

List<Vector2> spread(
  1. int amount
)

Spreads points evenly along the line segment. A number of points amount are returned; the edges are not included.

Implementation

List<Vector2> spread(int amount) {
  if (amount < 0) {
    throw ArgumentError('Amount must be non-negative');
  }
  if (amount == 0) {
    return [];
  }

  final step = length / (amount + 1);
  return [
    for (var i = 1; i <= amount; i++) from + direction * (i * step),
  ];
}