Add wrapper-class output style option for generated colors#766
Open
ugoostanleyibe wants to merge 2 commits into
Open
Add wrapper-class output style option for generated colors#766ugoostanleyibe wants to merge 2 commits into
wrapper-class output style option for generated colors#766ugoostanleyibe wants to merge 2 commits into
Conversation
Add an opt-in `colors/outputs/style` option to the colors generator. The new `wrapper-class` style generates a color class that `extends Color` with a forwarding const constructor, exposing each color as a `static const` of the generated type (no explicit annotation). Material colors additionally emit a `<name>Swatch` (MaterialColor) / `<name>AccentSwatch` (MaterialAccentColor) alongside the base color. The default `plain` style (`abstract final class` with `static const Color`) is unchanged and remains the default, so existing users are unaffected. - Add FlutterGenElementColorsOutputsStyle enum + FlutterGenElementColorsOutputs - Branch colors_generator on the configured style - Default config + README documentation - Tests: new fixture/fact, generator test case, enum fromJson/toJson tests - Showcase the new style in the example apps Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The wrapper-class color style was incorrectly emitting an extra base `<name>` constant and appending a `Swatch` suffix to every material color. Material colors already carry their own names in the source XML (e.g. a `seaBlueSwatch` material entry alongside a separate `seaBlue` normal color), so this produced duplicated/`SwatchSwatch` output. Material and material-accent colors are now emitted identically to the `plain` style. Only normal colors change in the wrapper-class style (they use the generated type's const constructor with no annotation). - Fix _colorStatement; regenerate fixture fact and example output - Restore example main.dart primarySwatch to the material color name - Correct README/CHANGELOG/doc-comment wording Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
wrapper-class output style option for generated colors
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.
What does this change?
Adds a
wrapper-classoutput style option so generated colors are a Color subtype (usable with dot shorthands)Fixes #765 🎯
Type of change
Please delete options that are not relevant.
Checklist:
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
melos run test)melos run formatto automatically apply formatting)