ListItem.fromJson constructor
ListItem.fromJson(
- Map<String, dynamic> json
)
Implementation
factory ListItem.fromJson(Map<String, dynamic> json) {
// BUG WORKAROUND: _$ListItemFromJson first calls ..children = [...] then
// ..fragments = [...]. The `fragments` setter of ListItem overrides
// children with a single wrapper Paragraph, destroying the actual
// structure (e.g. nested sublists). Restore the real children from JSON.
final item = _$ListItemFromJson(json);
final rawChildren = json['children'] as List<dynamic>?;
if (rawChildren != null) {
item.children = rawChildren
.map((e) =>
const FNodeJsonConverter().fromJson(e as Map<String, dynamic>))
.toList();
}
return item;
}