DVDocumentBlock.fromJson constructor

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

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),
  };
}