encodeBlock function
Encodes one block, with the same two-part shape as
encodeBookDocument: an ImageBlock's bytes arrive in the returned
images map, not in the json.
Exported so a consumer that stores something block-shaped of its own — a paginated wrapper, for instance — composes with this instead of writing a second block serialiser.
Implementation
({Map<String, dynamic> json, Map<String, ImageData> images}) encodeBlock(
Block block) {
final images = <String, ImageData>{};
final json = _blockJson(block, images);
json['v'] = kBookDocumentSchemaVersion;
return (json: json, images: images);
}