fill method

void fill(
  1. int value, [
  2. int? start,
  3. int? end
])

Fills this array with the specified value.

value the value to fill with (0-255) start the starting index (optional) end the ending index (optional)

Implementation

void fill(int value, [int? start, int? end]) {
  if (value < 0 || value > 255) {
    throw InvalidArgumentException('Fill value must be between 0 and 255, got: $value');
  }

  int startIndex = start ?? 0;
  int endIndex = end ?? _bytes.length;

  for (int i = startIndex; i < endIndex; i++) {
    _bytes[i] = value;
  }
}