encode method
Encode this header into a fresh 100-byte buffer.
Implementation
Uint8List encode() {
final out = Uint8List(100);
out.setRange(0, 16, magic);
final bd = ByteData.sublistView(out);
bd.setUint16(16, pageSize == 65536 ? 1 : pageSize);
bd.setUint8(18, fileFormatWrite);
bd.setUint8(19, fileFormatRead);
bd.setUint8(20, reservedSpace);
// Bytes 21..23 are fixed magic constants required by SQLite.
bd.setUint8(21, 64); // max embedded payload fraction
bd.setUint8(22, 32); // min embedded payload fraction
bd.setUint8(23, 32); // leaf payload fraction
bd.setUint32(24, 0); // file change counter
bd.setUint32(28, dbSizeInPages);
bd.setUint32(32, 0); // first freelist trunk
bd.setUint32(36, 0); // total freelist pages
bd.setUint32(40, schemaCookie);
bd.setUint32(44, schemaFormat);
bd.setUint32(48, 0); // default page cache size
bd.setUint32(52, 0); // largest root b-tree page (autovacuum)
bd.setUint32(56, textEncoding);
bd.setUint32(60, userVersion);
bd.setUint32(64, 0); // incremental-vacuum mode
bd.setUint32(68, applicationId);
// Bytes 72..91 are reserved; left as zero.
bd.setUint32(92, 0); // version-valid-for number
bd.setUint32(96, 3045000); // SQLite version (3.45.0) — informational.
return out;
}