rangeToInclusive method

List<int> rangeToInclusive(
  1. int end
)

Returns a list of integers from this number to end (inclusive).

Example:

1.rangeToInclusive(5); // [1, 2, 3, 4, 5]

Implementation

List<int> rangeToInclusive(int end) {
  if (end < this) return [];
  return List.generate(end - this + 1, (index) => this + index);
}