ChangeContentOverlay.fromJson constructor

ChangeContentOverlay.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json
)

Implementation

factory ChangeContentOverlay.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  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));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'edits');
    }
    return ChangeContentOverlay(edits);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'ChangeContentOverlay', json);
  }
}