decode method Null safety

void decode(
  1. KeyedArchive object
)
override

Implementation

void decode(KeyedArchive object) {
  super.decode(object);

  title = object.decode("title");
  maximum = object.decode("maximum");
  exclusiveMaximum = object.decode("exclusiveMaximum");
  minimum = object.decode("minimum");
  exclusiveMinimum = object.decode("exclusiveMinimum");
  maxLength = object.decode("maxLength");
  minLength = object.decode("minLength");
  pattern = object.decode("pattern");
  maxItems = object.decode("maxItems");
  minItems = object.decode("minItems");
  uniqueItems = object.decode("uniqueItems");
  multipleOf = object.decode("multipleOf");
  enumerated = object.decode("enum");
  minProperties = object.decode("minProperties");
  maxProperties = object.decode("maxProperties");
  required = object.decode("required");

  //

  type = APITypeCodec.decode(object.decode("type"));
  allOf = object.decodeObjects("allOf", () => new APISchemaObject());
  anyOf = object.decodeObjects("anyOf", () => new APISchemaObject());
  oneOf = object.decodeObjects("oneOf", () => new APISchemaObject());
  not = object.decodeObject("not", () => new APISchemaObject());

  items = object.decodeObject("items", () => new APISchemaObject());
  properties =
      object.decodeObjectMap("properties", () => new APISchemaObject())
          as Map<String, APISchemaObject>?;

  final addlProps = object["additionalProperties"];
  if (addlProps is bool) {
    if (addlProps) {
      additionalPropertyPolicy = APISchemaAdditionalPropertyPolicy.freeForm;
    } else {
      additionalPropertyPolicy = APISchemaAdditionalPropertyPolicy.disallowed;
    }
  } else if (addlProps is KeyedArchive && addlProps.isEmpty) {
    additionalPropertyPolicy = APISchemaAdditionalPropertyPolicy.freeForm;
  } else {
    additionalPropertyPolicy = APISchemaAdditionalPropertyPolicy.restricted;
    additionalPropertySchema = object.decodeObject(
        "additionalProperties", () => new APISchemaObject());
  }

  description = object.decode("description");
  format = object.decode("format");
  defaultValue = object.decode("default");

  _nullable = object.decode("nullable");
  _readOnly = object.decode("readOnly");
  _writeOnly = object.decode("writeOnly");
  _deprecated = object.decode("deprecated");
}