getString method

String getString(
  1. int index
)

Gets the string value at the specified index.

Decodes the stored UTF-8 bytes to a Dart string.

@param index The index from which to get the string. @return The string value. @throws RangeError if the index is out of bounds.

Implementation

String getString(int index) {
  if (index >= length) {
    throw RangeError('Index out of bounds');
  }

  final buffer = data[index].asTypedList(stringCapacity);
  var end = 0;
  while (end < stringCapacity && buffer[end] != 0) {
    end++;
  }
  return utf8.decode(buffer.sublist(0, end));
}