finish method

Uint8List finish(
  1. int offset, [
  2. String? fileIdentifier
])

Finish off the creation of the buffer. The given offset is used as the root object offset, and usually references directly or indirectly every written object. If fileIdentifier is specified (and not null), it is interpreted as a 4-byte Latin-1 encoded string that should be placed at bytes 4-7 of the file.

Implementation

Uint8List finish(int offset, [String? fileIdentifier]) {
  _prepare(max(_sizeofUint32, _maxAlign), fileIdentifier == null ? 1 : 2);
  _setUint32AtTail(_buf, size, size - offset);
  if (fileIdentifier != null) {
    for (int i = 0; i < 4; i++) {
      _setUint8AtTail(
          _buf, size - _sizeofUint32 - i, fileIdentifier.codeUnitAt(i));
    }
  }
  return _buf.buffer.asUint8List(_buf.lengthInBytes - size);
}