RichTextLeaf.fromJson constructor

RichTextLeaf.fromJson(
  1. JSONMap json
)

Implementation

factory RichTextLeaf.fromJson(JSONMap json) {
  final type = json["type"];
  return switch (type) {
    "text" => RichTextLeafText.fromJson(json),
    "emoji" => RichTextLeafEmoji.fromJson(json),
    "image" => RichTextLeafImage.fromJson(json),
    "hard_break" => RichTextLeafHardBreak(),
    "paragraph" => RichTextContainerParagraph.fromJson(json),
    _ => UnrecognizedRichTextLeaf(type, json),
  } as RichTextLeaf;
}