AddContentOverlay.fromJson constructor

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

Implementation

factory AddContentOverlay.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    if (json['type'] != 'add') {
      throw jsonDecoder.mismatch(jsonPath, 'equal add', json);
    }
    String content;
    if (json.containsKey('content')) {
      content =
          jsonDecoder.decodeString('$jsonPath.content', json['content']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'content');
    }
    return AddContentOverlay(content);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'AddContentOverlay', json);
  }
}