EditableBlock.fromPostBlock constructor
Reconstrói um EditableBlock a partir de um PostBlock salvo.
Implementation
factory EditableBlock.fromPostBlock(int id, PostBlock block) {
final e = EditableBlock(id, _typeOf(block));
switch (block) {
case ParagraphBlock(:final text):
e.text = text;
case HeadingBlock(:final text, :final level):
e.text = text;
e.level = level;
case ImageBlock(:final url, :final caption, :final credit):
e.url = url;
e.text = caption ?? '';
e.secondary = credit ?? '';
case QuoteBlock(:final text, :final cite):
e.text = text;
e.secondary = cite ?? '';
case ListBlock(:final items, :final ordered):
e.text = items.join('\n');
e.ordered = ordered;
case EmbedBlock(:final html):
e.text = html;
case DividerBlock():
break;
}
return e;
}