DVPageData.fromJson constructor
A page from what toJson wrote. Throws FormatException for anything that is not one, so a cache holding something else is ignored rather than served as a page with no title.
Implementation
factory DVPageData.fromJson(Map<String, Object?> json) {
final Object? title = json['title'];
if (title is! String) {
throw const FormatException('a kept page has no title, so it is not a page');
}
return DVPageData(
title: title,
description: json['description'] as String?,
image: json['image'] as String?,
favicon: json['favicon'] as String?,
text: <String>[for (final Object? line in (json['text'] as List?) ?? const <Object?>[]) '$line'],
structuredData: json['structuredData'] is Map
? (json['structuredData']! as Map).cast<String, Object?>()
: null,
visibility: DVPageVisibility.values.firstWhere(
(DVPageVisibility v) => v.name == json['visibility'],
orElse: () => DVPageVisibility.public,
),
);
}