readSceneProps function

void readSceneProps(
  1. SceneNode node,
  2. Map<String, Object?> json
)

Every table property of node off json, the default where the key is absent — shared by the authored plane and the wire, which spell values the same way and differ only in what else they carry.

Implementation

void readSceneProps(SceneNode node, Map<String, Object?> json) {
  for (var p in scenePropsOf(node)) {
    if (!p.onWire) continue;
    // A legacy payload packed the border as [argb, width].
    if (p.name == 'borderColor' && json['border'] is List) {
      var l = json['border']! as List;
      node.borderColor = l.isNotEmpty
          ? SceneColor((l[0] as num).toInt())
          : null;
      node.borderWidth = l.length > 1 ? (l[1] as num).toDouble() : 1;
      continue;
    }
    if (p.name == 'borderWidth' && json.containsKey('border')) continue;
    var raw = json[p.key];
    if (raw == null && !json.containsKey(p.key)) {
      // Missing means default — except where null IS the value.
      if (p.kind != ScenePropKind.size && p.kind != ScenePropKind.integer) {
        p.write(node, p.defaultValue);
        continue;
      }
    }
    p.write(node, p.fromWire(raw));
  }
}