You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/genui/skills/create-catalog-item/SKILL.md
+3-4Lines changed: 3 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ description: Use this skill when the user asks to create a new CatalogItem, data
6
6
# Create CatalogItem
7
7
8
8
## Goal
9
-
To correctly implement a GenUI CatalogItem based on a provided json_schema_builder Schema, including its corresponding data class, top-level function, and Widget class. This ensures the AI model can properly generate and interact with the UI component.
9
+
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.
10
10
11
11
## Instructions
12
12
When tasked with creating a CatalogItem from a `Schema`, follow these steps:
@@ -19,7 +19,7 @@ When tasked with creating a CatalogItem from a `Schema`, follow these steps:
19
19
- Cast each property from the `json` map to its expected type, e.g., `title: json['title'] as String,` or `action: json['action'] as JsonMap?,`.
20
20
- Throw an `Exception('Invalid JSON for _<SchemaName>Data')` in the `catch` block if an error occurs.
21
21
22
-
2.**Create the CatalogItem Top-Level Function**:
22
+
2.**Create the CatalogItem Instance**:
23
23
- Name it identical to the schema name but without the "Schema" suffix (e.g., `myCard` for `myCardSchema`).
24
24
- Declare as a `final CatalogItem`.
25
25
- Set `name` to the capitalized version of the name (e.g., `'MyCard'`).
@@ -83,8 +83,7 @@ final basicCard = CatalogItem(
83
83
final action = data.action;
84
84
if (action == null) return;
85
85
final event = action['event'] as JsonMap?;
86
-
final name = event?['name'] as String?;
87
-
if (name == null || name.isEmpty) return;
86
+
final name = (event?['name'] as String?) ?? '';
88
87
final JsonMap contextDefinition =
89
88
(event?['context'] as JsonMap?) ?? <String, Object?>{};
90
89
final JsonMap resolvedContext = await resolveContext(
0 commit comments