schema/json_reader library

Functions

closedEnum(Object? value, Set<String> allowed, String path, {String? ifAbsent}) String
Reads a closed-set string, where path already names the key.
object(Map<String, dynamic> json, String key, String path) Map<String, dynamic>?
Reads an optional sub-object. Absent reads as null; present but not an object throws.
objects(Map<String, dynamic> json, String key, String path) List<Map<String, dynamic>>
Reads a list of JSON objects at key. Missing reads as empty; a non-object element is a contract violation and throws.
opt<T>(Map<String, dynamic> json, String key) → T?
Reads an optional key of type T. A wrong type reads as absent — the server is allowed to widen a field without breaking older clients.
req<T>(Map<String, dynamic> json, String key, String path) → T
Reads a required key of type T, throwing with the JSON path if absent or of the wrong type.
stringList(Map<String, dynamic> json, String key) List<String>
Reads a flat list of strings at key, dropping any non-string element. Missing or wrong-shaped reads as an empty list — the same tolerant widening as opt, for a key that is ORDERING metadata rather than a source of truth (panel.locales): a malformed value degrading to "no preferred order" is harmless, so it is never worth a thrown exception.
stringMap(Map<String, dynamic> json, String key) Map<String, String>
Reads a {"key": "value"} map, dropping any non-string value.

Exceptions / Errors

SchemaFormatException
Thrown when the panel JSON does not match the contract.