insert method

void insert(
  1. int index,
  2. int byte
)

Inserts a byte at the specified index.

Example:

final bytes = Byte.fromList([1, 3, 4]);
bytes.insert(1, 2);
print(bytes.toList());  // [1, 2, 3, 4]

Throws InvalidArgumentException if value is outside byte range. Throws RangeError if index is invalid.

Implementation

void insert(int index, int byte) {
  _bytes.insert(index, _validateByteRange(byte));
}