writePage method
Implementation
Future<void> writePage(int pageIndex, String text) async {
if (_closed) return;
final File? file = _file;
if (file == null) {
_memory[pageIndex] = text;
return;
}
_writer ??= await file.open(mode: FileMode.append);
final Uint8List line = Uint8List.fromList(utf8.encode("${jsonEncode(<String, Object?>{"p": pageIndex, "t": text})}\n"));
await _writer!.writeFrom(line);
_offsets[pageIndex] = _tail;
_lengths[pageIndex] = line.length - 1;
_tail += line.length;
_cache.put(pageIndex, text);
}