Content.fromJson constructor
Content.fromJson(
- Map<String, dynamic> json
)
Implementation
factory Content.fromJson(Map<String, dynamic> json) {
final type = json['type'] as String?;
assert(type != null, 'type is required');
switch (type) {
case 'audio':
return AudioContent.fromJson(json);
case 'text':
return TextContent.fromJson(json);
case 'video':
return VideoContent.fromJson(json);
case 'markdown':
return MarkdownContent.fromJson(json);
case 'lottie':
return LottieContent.fromJson(json);
default:
throw Exception('Unknown type: $type');
}
}