ContentBlock.fromJson constructor
Reads the branch json names; an unrecognised one is kept as UnknownContentBlock.
Implementation
factory ContentBlock.fromJson(Map<String, Object?> json) {
switch (json['type']) {
case 'text':
return TextContent.fromJson(json);
case 'image':
return ImageContent.fromJson(json);
case 'audio':
return AudioContent.fromJson(json);
case 'resource_link':
return ResourceLink.fromJson(json);
case 'resource':
return EmbeddedResource.fromJson(json);
}
return UnknownContentBlock.fromJson(json);
}