create-catalog-item
Installation
SKILL.md
Create CatalogItem
Goal
To correctly implement a GenUI CatalogItem based on a provided json_schema_builder Schema, including its corresponding data class, CatalogItem instance, and Widget class. This ensures the AI model can properly generate and interact with the UI component.
Instructions
When tasked with creating a CatalogItem from a Schema, follow these steps:
-
Create the Data Class:
- Name it
_<SchemaName>Data(e.g., if schema ismyCardSchema, data class is_MyCardData). - Add final fields for each property defined in the schema.
- Create a
factory _<SchemaName>Data.fromJson(Map<String, Object?> json)method. - Use a
try-catchblock to parse the properties and return a new instance. - Cast each property from the
jsonmap to its expected type, e.g.,title: json['title'] as String,oraction: json['action'] as JsonMap?,. - Throw an
Exception('Invalid JSON for _<SchemaName>Data')in thecatchblock if an error occurs.
- Name it
-
Create the CatalogItem Instance:
- Name it identical to the schema name but without the "Schema" suffix (e.g.,
myCardformyCardSchema). - Declare as a
final CatalogItem.
- Name it identical to the schema name but without the "Schema" suffix (e.g.,
Related skills