EnumSchema.fromJson constructor

EnumSchema.fromJson(
  1. Map<String, Object?> json
)

Reads the branch json names; an unrecognised one is kept as UnknownEnumSchema.

Implementation

factory EnumSchema.fromJson(Map<String, Object?> json) {
  if ({'array'}.contains(json['type']) && json.containsKey('items') && (json['items'] is Map && (json['items'] as Map).containsKey('enum'))) return UntitledMultiSelectEnumSchema.fromJson(json);
  if ({'array'}.contains(json['type']) && json.containsKey('items') && (json['items'] is Map && (json['items'] as Map).containsKey('anyOf'))) return TitledMultiSelectEnumSchema.fromJson(json);
  if ({'string'}.contains(json['type']) && json.containsKey('enum') && (json.containsKey('enumNames'))) return LegacyTitledEnumSchema.fromJson(json);
  if ({'string'}.contains(json['type']) && json.containsKey('enum')) return UntitledSingleSelectEnumSchema.fromJson(json);
  if ({'string'}.contains(json['type']) && json.containsKey('oneOf')) return TitledSingleSelectEnumSchema.fromJson(json);
  return UnknownEnumSchema.fromJson(json);
}