toDartString method

String toDartString({
  1. int? length,
})

Implementation

String toDartString({int? length}) {
  final codeUnits = this.cast<ffi.Uint8>();
  final list = <int>[];

  if (length != null) {
    RangeError.checkNotNegative(length, 'length');
  } else {
    length = _length(codeUnits);
  }
  for (int i = 0; i < length; i++) {
    list.add(codeUnits.elementAt(i).value);
  }
  return utf8.decode(list);
}