fromJson static method

IrNode fromJson(
  1. Map<String, Object?> json
)

Implementation

static IrNode fromJson(Map<String, Object?> json) {
  final node = switch (json['type']) {
    'frame' => IrFrame._fromJson(json),
    'text' => IrText._fromJson(json),
    'vector' => IrVector._fromJson(json),
    _ => throw FormatException('Unknown IR node type: ${json['type']}'),
  };
  node
    ..origin = [...(json['origin'] as List? ?? const []).cast<String>()]
    ..source = json['source'] as String?
    ..position = IrPosition.fromJson(json['position'])
    ..rotation = _d(json['rotation']) ?? 0
    ..instance = IrInstanceRef.fromJson(json['instance']);
  return node;
}