setString method
Writes an `encoded value to a region of the buffer.
Returns the position of the last element written to the buffer (offset + decoded-length).
The encoded value is written to the range [offset : offset+length]. If length is omitted, the range extends to the end of the buffer.
The range must satisfy the relations 0 ≤ offset ≤ offset+length ≤ this.length.
Implementation
int setString(
final String value,
final BufferEncoding encoding, [
final int offset = 0,
final int? length,
]) {
final Iterable<int> bytes = _decode(value, encoding);
final int rngLength = length ?? min(this.length - offset, bytes.length);
_data.setRange(offset, offset + rngLength, bytes);
return offset + rngLength;
}