feat(catalog): consolidate component name into CatalogItem constructor#757
Merged
gspencergoog merged 3 commits intoflutter:mainfrom Feb 24, 2026
Merged
feat(catalog): consolidate component name into CatalogItem constructor#757gspencergoog merged 3 commits intoflutter:mainfrom
gspencergoog merged 3 commits intoflutter:mainfrom
Conversation
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.
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Extracts the
nameproperty directly to theCatalogItemconstructor. TheCatalogItemnow explicitly takesnameas a required parameter string, and automatically injects the requiredcomponentdiscriminator into the data schema when thedataSchemais evaluated.This reduces repetitive boilerplate across the 19 basic catalog widgets by removing the redundant
componentschema definition mapping and the manual inclusion ofcomponentin the properties list. The constructor parameter accepts theSchematype allowing the developer to instantiateS.object(…)smoothly while structurally enforcingObjectSchemaexternally.Fixes #735