DartBlockEvaluationSchema.fromJson constructor

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

Implementation

factory DartBlockEvaluationSchema.fromJson(Map<String, dynamic> json) {
  DartBlockEvaluationSchemaType? kind;
  if (json.containsKey('schemaType')) {
    for (var schemaType in DartBlockEvaluationSchemaType.values) {
      if (json["schemaType"] == schemaType.jsonValue) {
        kind = schemaType;
        break;
      }
    }
  }

  if (kind == null) {
    throw EvaluatorSchemaSerializationException(
      json.containsKey("schemaType") ? json["schemaType"] : "UNKNOWN",
    );
  }
  switch (kind) {
    case DartBlockEvaluationSchemaType.functionDefinition:
      return DartBlockFunctionDefinitionEvaluationSchema.fromJson(json);
    case DartBlockEvaluationSchemaType.functionOutput:
      return DartBlockFunctionOutputEvaluationSchema.fromJson(json);
    case DartBlockEvaluationSchemaType.script:
      return DartBlockScriptEvaluationSchema.fromJson(json);
    case DartBlockEvaluationSchemaType.variableCount:
      return DartBlockVariableCountEvaluationSchema.fromJson(json);
    case DartBlockEvaluationSchemaType.environment:
      return DartBlockEnvironmentEvaluationSchema.fromJson(json);
    case DartBlockEvaluationSchemaType.print:
      return DartBlockPrintEvaluationSchema.fromJson(json);
  }
}