fromJson static method

Story fromJson(
  1. Map<String, dynamic> map, {
  2. ImageResolver? imageResolver,
})

Initializes the story from the input json.

Implementation

static Story fromJson(Map<String, dynamic> map,
    {ImageResolver? imageResolver}) {
  var rootMap = map["root"] as Map<String, dynamic>;
  var rootPage = Page.fromMap(rootMap);
  var currentPageMap = map['currentPage'];
  var currentPage;
  if (currentPageMap == null) {
    currentPage = rootPage;
  } else {
    currentPage = Page.fromMap(currentPageMap);
  }

  List? historyList = map['history'];
  String authors = map["authors"];
  return Story(
    title: map['title'],
    description: map['description'],
    root: rootPage,
    authors: authors,
    year: map['year'],
    currentPage: currentPage,
    imageResolver: imageResolver,
    existingHistory: historyList == null
        ? []
        : historyList.map((item) => HistoryItem.fromMap(item)).toList(),
  );
}