decode method Null safety

  1. @override
void decode(
  1. KeyedArchive object
)
override

Implementation

@override
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");
  isRequired = object.decode("required");

  //

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

  items = object.decodeObject("items", () => APISchemaObject());
  properties = object.decodeObjectMap("properties", () => 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", () => 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");
}