notationOptionsFor function
The options printNotation's output is parsed with: the document's canvas id and width, and no reflow: a document printed is as it is, its media rules written on its lines. A component's document has no canvas: its screen is a name none of its nodes has.
Implementation
NotationOptions notationOptionsFor(Json document) {
final roots = readStrings(document['roots']);
final nodes = readMap(document['nodes']) ?? const {};
final first = roots.isEmpty ? 'screen' : roots.first;
final canvas = readMap(nodes[first]);
if (canvas != null && canvas['type'] != 'canvas') {
var screen = 'screen';
for (var i = 2; nodes.containsKey(screen); i++) {
screen = 'screen$i';
}
return NotationOptions(screen: screen, reflow: false);
}
final width = readMap(canvas?['layout'])?['width'];
return NotationOptions(screen: first, width: width is num ? width.toDouble() : 390, reflow: false);
}