refactor: generate Mix styling layer with mix_generator#98
Merged
Conversation
Replace ~1,450 lines of hand-written Spec/Styler boilerplate (copyWith, lerp, resolve, merge, props, debugFillProperties) with mix_generator output, the same codegen Mix 2.x uses for its own specs. - Leaf specs (alert type, blockquote, checkbox, codeblock, list, table) are fully spec-driven: @MixableSpec generates the *Styler class. - Aggregators (slide, markdown_alert) nest same-package generated stylers, which @MixableField(setterType:) cannot reference during generation, so their stylers stay hand-written on the legacy @MixableStyler mixin path (fields + constructors only). - Canonical styler names follow the Mix idiom (*Styler); old *Style names remain as typedef aliases. - BREAKING: TextStyle-typed styler params are now TextStyleMix and gain Mix field-wise merge semantics. - Stylers gain generated fluent setters, field factories, and widget-state variant helpers (onHovered, onFocused, ...). - Drop vestigial custom_lint dev dep (no plugin configured; it pinned analyzer <9 and blocked mix_generator). - Changelog the MarkdownText* deprecation shipped in #97. Impacted packages: superdeck (styling, deck, markdown, tests), demo, playground, plugins/pdf (rename only), docs. Verified: melos run analyze (dart + DCM) green; superdeck 654 tests and pdf 27 tests pass incl. goldens; .g.dart output byte-identical when regenerated from a clean build cache.
The root CHANGELOG.md was a drifted copy of packages/superdeck's (stale at 1.0.0, missing the Unreleased section). Per-package changelogs are the source of truth in this monorepo; make the root file a pointer so it cannot drift again.
|
To preview the documentation for this pull request, visit the following URL:
|
|
Visit the preview URL for this PR (updated for commit 6f6cd87): https://superdeck-dev--pr98-leoafarias-mix-codeg-fofbz161.web.app (expires Tue, 11 Aug 2026 17:54:24 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: bd68fc230762285849207e7e120aaf87cd4ca2f9 |
Collaborator
Author
|
Upstream generator change is up: btwld/mix#961 — once it ships in mix_generator 2.1.2, the two aggregator stylers here ( |
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.
Intent
Replace ~1,450 lines of hand-written Mix Spec/Styler boilerplate (
copyWith,lerp,resolve,merge,props,debugFillProperties) withmix_generatoroutput — the same codegen Mix 2.x uses for its own specs. Net −1,160 hand-written lines in the styling layer; what remains by hand is only what carries meaning (field declarations, constructor defaults,SlideSpec.of,toStyle()).Architecture
Two tiers, split for a reason proven empirically before committing:
@MixableSpecgenerates the entire*Stylerclass, including a fluent API these classes never had (per-field setters, field factories,onHovered/onFocusedvariant helpers).slide.dart,markdown_alert.dart): generated spec mixin + hand-written styler (fields + two constructors) on the legacy@MixableStylermixin. Forced: nested custom specs need@MixableField(setterType: MarkdownAlertStyler), but annotation type arguments cannot reference same-package generated classes — build phases hide them from the resolver and the generator silently degrades to value semantics (replacement instead of Mix merge accumulation). Hand-written constructors can reference generated classes freely, so the hybrid keeps correctProp.maybeMixsemantics. Rationale recorded inbuild.yamland both file headers.Breaking changes
*Styler(SlideStyler,MarkdownAlertStyler, ...) per the Mix idiom; old*Stylenames remain as typedef aliases.TextStyle-typed styler params are nowTextStyleMix(wrap existing values withTextStyleMix.value(...)); these fields gain Mix field-wise merge semantics through the style cascade.Also in this PR
custom_lintdev dep (no plugin configured anywhere; it pinnedanalyzer <9and hard-blockedmix_generator).MarkdownText*deprecation that shipped unchangelogged in fix: apply SlideSpec styles to inline Markdown #97.CHANGELOG.mdwas a drifted copy of the package changelog; it now points at per-package changelogs.Impacted packages
superdeck(styling, deck, markdown, tests),demo,playground,plugins/pdf(rename only),docs.Verification
melos run analyze(dart analyze + DCM, fatal warnings) green across all packagesflutter test: superdeck 654/654, pdf plugin 27/27 — goldens included.g.dartoutput regenerates byte-identically from a clean build cache in a single pass, with zero degraded setters (grep-verifiedProp.maybeMixon all nested spec fields)Follow-up
mix_generatorcould derive nestedStyleSpec<XSpec>setter types by the sameXSpec → XStylernaming convention it already uses for class names — pure string derivation, no analyzer resolution — which would let the two aggregators go fully spec-driven and delete everysetterType:annotation. Upstream PR against btwld/mix incoming.