ChangeContentOverlay.fromJson constructor

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

Implementation

factory ChangeContentOverlay.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json,
    {ClientUriConverter? clientUriConverter}) {
  json ??= {};
  if (json is Map) {
    if (json['type'] != 'change') {
      throw jsonDecoder.mismatch(jsonPath, 'equal change', json);
    }
    List<SourceEdit> edits;
    if (json.containsKey('edits')) {
      edits = jsonDecoder.decodeList(
          '$jsonPath.edits',
          json['edits'],
          (String jsonPath, Object? json) => SourceEdit.fromJson(
              jsonDecoder, jsonPath, json,
              clientUriConverter: clientUriConverter));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'edits');
    }
    return ChangeContentOverlay(edits);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'ChangeContentOverlay', json);
  }
}