Document.fromJson constructor
Constructs a Document from a JSON strcuture.
Example of a Document in JSON format:
{
'document': {
'type': 'page',
'children': [
{
'type': 'paragraph',
'data': {
'delta': [
{ 'insert': 'Welcome ' },
{ 'insert': 'to ' },
{ 'insert': 'AppFlowy!' }
]
}
}
]
}
}
Implementation
factory Document.fromJson(Map<String, dynamic> json) {
assert(json['document'] is Map);
final document = Map<String, Object>.from(json['document'] as Map);
final root = Node.fromJson(document);
return Document(root: root);
}