AddContentOverlay.fromJson constructor

AddContentOverlay.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json, {
  4. ClientUriConverter? clientUriConverter,
})

Implementation

factory AddContentOverlay.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(jsonPath, "'AddContentOverlay'", json);
  }
  if (json['type'] != 'add') {
    throw jsonDecoder.mismatch(jsonPath, "equal to 'add'", json);
  }
  String content;
  if (json case {'content': var encodedContent}) {
    content = jsonDecoder.decodeString('$jsonPath.content', encodedContent);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'content'", json);
  }
  int? version;
  if (json case {'version': var encodedVersion}) {
    version = jsonDecoder.decodeInt('$jsonPath.version', encodedVersion);
  }
  return AddContentOverlay(content, version: version);
}