close method
Closes the writer and finalizes the map file.
This method closes the underlying file sink and then re-opens the file to write the final, correct file size into the header, as this value is not known until all data has been written.
Implementation
///
/// This method closes the underlying file sink and then re-opens the file to
/// write the final, correct file size into the header, as this value is not
/// known until all data has been written.
Future<void> close() async {
await _sink.close();
// todo correct invalid data in file
RandomAccessFile raf = await File(filename).open(mode: FileMode.writeOnlyAppend);
// position of filesize
Writebuffer writebuffer = Writebuffer();
int length = await File(filename).length();
writebuffer.appendInt8(length);
await writebuffer.writeIntoAt(28, raf);
await raf.close();
}