fromJson static method

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

converts json to an instance

Implementation

static dynamic? fromJson(Map<String, dynamic>? json) {
  _init();
  if (json == null) {
    return null;
  }
  final typeStr = json['type'] as String?;
  if (json['type'] == _TYPE_SERIALIZABLE) {
    return json['data'];
  }
  final adapter = _adapterByTypeStr[typeStr];
  if (adapter == null) {
    throw StateError("Missing VoyagerAdapter for type `$typeStr` in $json");
  }
  if (json['data'] == null) {
    throw StateError("Missing field `data` in $json");
  }
  return adapter.deserialize(json['data']);
}