TocEntry.fromJson constructor

TocEntry.fromJson(
  1. Map<String, dynamic> json
)

Create a TocEntry from a map (for JSON deserialization).

Implementation

factory TocEntry.fromJson(Map<String, dynamic> json) {
  return TocEntry(
    id: json['id'] as String,
    text: json['text'] as String,
    depth: json['depth'] as int? ?? 2,
    children:
        (json['children'] as List<dynamic>?)
            ?.map((dynamic e) => TocEntry.fromJson(e as Map<String, dynamic>))
            .toList() ??
        const [],
  );
}