encodeInto method

TextEncoderEncodeIntoResult encodeInto(
  1. String source,
  2. Uint8List destination
)

Implementation

TextEncoderEncodeIntoResult encodeInto(String source, Uint8List destination) {
  var bytes = utf8.encode(source);
  var length = bytes.length;

  if (destination.length < length) {
    length = destination.length;
  }

  for (var i = 0; i < length; i++) {
    destination[i] = bytes[i];
  }

  return TextEncoderEncodeIntoResult(read: length, written: length);
}