Skip to content

Comments

feat(catalog): consolidate component name into CatalogItem constructor#757

Merged
gspencergoog merged 3 commits intoflutter:mainfrom
gspencergoog:consolidate_name
Feb 24, 2026
Merged

feat(catalog): consolidate component name into CatalogItem constructor#757
gspencergoog merged 3 commits intoflutter:mainfrom
gspencergoog:consolidate_name

Conversation

@gspencergoog
Copy link
Collaborator

@gspencergoog gspencergoog commented Feb 24, 2026

Description

Extracts the name property directly to the CatalogItem constructor. The CatalogItem now explicitly takes name as a required parameter string, and automatically injects the required component discriminator into the data schema when the dataSchema is evaluated.

This reduces repetitive boilerplate across the 19 basic catalog widgets by removing the redundant component schema definition mapping and the manual inclusion of component in the properties list. The constructor parameter accepts the Schema type allowing the developer to instantiate S.object(…) smoothly while structurally enforcing ObjectSchema externally.

Fixes #735

Extracts the `name` property directly to the `CatalogItem` constructor instead of dynamically parsing it from the A2UI component discriminator enum value. The `CatalogItem` now explicitly takes `name` as a required parameter strings, and automatically injects the required `component` discriminator into the data schema when the `dataSchema` is evaluated.

This reduces repetitive boilerplate across the 19 basic catalog widgets by removing the redundant `component` schema definition mapping and the manual inclusion of `component` in the properties list. The constructor parameter accepts the `Schema` type allowing the developer to instantiate `S.object(…)` smoothly while structurally enforcing `ObjectSchema` externally.
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a great refactoring that significantly reduces boilerplate code across the basic catalog widgets by centralizing the injection of the component discriminator into the CatalogItem. The implementation in CatalogItem.dataSchema is clean and effectively handles this logic. The changes across all widget files are consistent and correct. I have one suggestion to further improve the type safety of the CatalogItem constructor.

Copy link
Collaborator

@jacobsimionato jacobsimionato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!!

@gspencergoog gspencergoog merged commit dc04675 into flutter:main Feb 24, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autopopulate component name from CatalogItem name

2 participants