type property

JsonType? get type

The JsonType of this schema, if present.

Use this in switch statements to determine the type of schema and cast to the appropriate subtype.

Note that it is good practice to include a default case, to avoid breakage in the case that a new type is added.

This is not required, and commonly won't be present if one of the schema combinators (allOf, anyOf, oneOf, or not) are used.

Implementation

JsonType? get type => JsonType.values.firstWhereOrNull(
  (t) => (_value['type'] as String? ?? '') == t.typeName,
);