fromJson static method

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

Implementation

static ComponentSchema fromJson(Map<String, Object?> json) {
  if (json['type'] is! String) {
    throw FormatException('Malformed component schema: $json');
  }
  return ComponentSchema(
    json['type'] as String,
    doc: json['doc'] as String?,
    icon: json['icon'] as String?,
    version: (json['version'] as num?)?.toInt() ?? 1,
    formerTypes: json['formerTypes'] is List
        ? [for (final type in json['formerTypes'] as List) type as String]
        : const [],
    properties: [
      if (json['properties'] is List)
        for (final entry in json['properties'] as List)
          if (entry is Map)
            ComponentPropertyDef.fromJson(entry.cast<String, Object?>()),
    ],
    gizmo: GizmoSpec.fromJson(json['gizmo']),
  );
}