toUint8List method Null safety

  1. @override
Uint8List toUint8List ()
override

Implementation

@override
Uint8List toUint8List() {
  var len = length;
  if (buffer is Uint8List) {
    final b = buffer as Uint8List;
    if ((offset + len) > b.length) {
      len = b.length - offset;
    }
    final bytes =
        Uint8List.view(b.buffer, b.offsetInBytes + offset, len);
    return bytes;
  }
  var end = offset + len;
  if (end > buffer.length) {
    end = buffer.length;
  }
  return Uint8List.fromList(buffer.sublist(offset, end));
}