writeToSlot method

  1. @override
Pointer<Char> writeToSlot(
  1. int slot,
  2. String text, [
  3. int? bufferSize
])
override

Writes text into slot slot, reallocating if the current capacity is insufficient for the UTF-8 encoded length.

Always null-terminates the written string.

Implementation

@override
Pointer<Char> writeToSlot(int slot, String text, [int? bufferSize]) {
  final requiredBytes = Length(text, bufferSize);

  reallocSlotIfRequired(slot, requiredBytes);

  final dst = stringSlots[slot]
    .cast<Uint8>()
    .asTypedList(requiredBytes);

  dst.setAll(0, _lastBytes);
  dst[_lastBytes.length] = 0;

  return stringSlots[slot];
}