ContentBlock.fromJson constructor
Deserializes a JSON map produced by toJson, dispatching on type.
Implementation
factory ContentBlock.fromJson(Map<String, dynamic> json) {
return switch (json['type']) {
'text' => TextContent.fromJson(json),
'thinking' => ThinkingContent.fromJson(json),
'toolCall' => ToolCall.fromJson(json),
'image' => ImageContent.fromJson(json),
_ => throw FormatException('Unknown content block type: ${json['type']}'),
};
}