toStateJson method
Serializes the Story with the state, history and the currentPage to the Map.
Used to persist the Story with saved player's progress.
Implementation
Map<String, dynamic> toStateJson() {
return {
'title': title,
'description': description,
'authors': authors,
'root': root.toMap(),
'currentPage': currentPage.toStateMap(),
'year': year,
'history': history.map((historyItem) => historyItem.toMap()).toList(),
};
}