setString method
Sets the string value at the specified index.
Encodes the given string to UTF-8 and stores it in the allocated memory.
@param index The index at which to set the string. @param value The string value to set. @throws RangeError if the index is out of bounds. @throws ArgumentError if the string is too long for the capacity.
Implementation
void setString(int index, String value) {
if (index >= capacity) {
throw RangeError('Index out of bounds');
}
final bytes = utf8.encode(value);
if (bytes.length > stringCapacity) {
throw ArgumentError('String too long for capacity');
}
final buffer = data[index].asTypedList(stringCapacity);
buffer.fillRange(0, stringCapacity, 0);
buffer.setAll(0, bytes);
if (index >= length) {
length = index + 1;
}
}