DVDocumentBlock.fromJson constructor
The block from what toJson wrote; an unknown kind reads as a paragraph.
Implementation
factory DVDocumentBlock.fromJson(Map<String, Object?> json) {
final String text = '${json['text'] ?? ''}';
return switch (json['kind']) {
'heading' => DVDocumentBlock.heading(text, level: (json['level'] as num?)?.toInt() ?? 2),
'link' => DVDocumentBlock.link(text, json['href'] as String?),
_ => DVDocumentBlock.paragraph(text),
};
}