fix(mix): accept *ListMix on shadow styler methods so token refs work#932
fix(mix): accept *ListMix on shadow styler methods so token refs work#932tilucasoli wants to merge 2 commits into
Conversation
`BoxStyler().boxShadows(token.mix())` failed to compile because the styler methods took `List<BoxShadowMix>` while `BoxShadowToken.mix()` returns a `BoxShadowListMixRef` (which implements `BoxShadowListMix`, not the raw list type). Same problem on `.shadows()` for Box/Flex/StackBox and on `TextStyler.shadows()` with `ShadowToken`. Change the shadow styler-mixin signatures to accept the matching `*ListMix` wrapper and bypass the list-wrapping intermediate by calling `Prop.mix(value)` directly, which preserves token refs end-to-end. Breaking: literal-list callers wrap with `BoxShadowListMix([...])` / `ShadowListMix([...])`. Fixes #925 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
To view this pull requests documentation preview, visit the following URL: Documentation is deployed and generated using docs.page. |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
leoafarias
left a comment
There was a problem hiding this comment.
One verified medium-risk issue found around token-backed shadow list merging.
| /// Accepts a [BoxShadowListMix] so that both literal lists | ||
| /// (`BoxShadowListMix([shadow1, shadow2])`) and design-token references | ||
| /// (`boxShadowToken.mix()`) can be passed. | ||
| T boxShadows(BoxShadowListMix value) { |
There was a problem hiding this comment.
This handles direct BoxShadowToken.mix() usage, but it does not preserve the existing BoxShadowListMix merge semantics when the token-backed list is merged with a later literal list.
I verified this with a focused failing widget test:
final styler = BoxStyler()
.boxShadows(token.mix()) // token resolves to BoxShadow(color: blue, blurRadius: 4)
.boxShadows(BoxShadowListMix([BoxShadowMix(color: Colors.red)]));The resolved shadow keeps the later red color, but blurRadius becomes 0.0 instead of preserving the token value 4. During resolution, Prop also logs that it cannot convert List<BoxShadow> to Mix<List<BoxShadow>>, so the token-resolved concrete list is skipped when Mix values are merged. The same issue reproduces for TextStyler.shadows with ShadowToken / List<Shadow>.
Existing shadow-list tests already establish index-wise in-place merge behavior for literal lists, so token-backed list sources should keep that behavior too. Please add conversion/normalization for List<BoxShadow> and List<Shadow> into BoxShadowListMix / ShadowListMix during mixed-source resolution, and add regression tests for token + literal list merges.
Summary
BoxStyler().boxShadows(token.mix())failed to compile because the shadow styler methods tookList<BoxShadowMix>whileBoxShadowToken.mix()returns aBoxShadowListMixRef(implementsBoxShadowListMix, not the raw list type). The same gap blocked.shadows()on Box/Flex/StackBox stylers andTextStyler.shadows()withShadowToken.*ListMixwrapper and route throughProp.mix(value)so token refs flow end-to-end. Regenerated the affected.g.dartfactory files; updatedmix_tailwinds/tw_parser.dartfor parity.BoxShadowListMix([...])/ShadowListMix([...]). Logged underUnreleasedinpackages/mix/CHANGELOG.md.Fixes #925.
What changed
packages/mix/lib/src/style/mixins/shadow_style_mixin.dartboxShadows(List<BoxShadowMix>)→boxShadows(BoxShadowListMix)packages/mix/lib/src/style/mixins/decoration_style_mixin.dartshadows(List<BoxShadowMix>)→shadows(BoxShadowListMix)packages/mix/lib/src/style/mixins/text_style_mixin.dartshadows(List<ShadowMix>)→shadows(ShadowListMix)packages/mix/lib/src/specs/{box,flexbox,stackbox,text}/*.g.dartBoxStyler.shadows/FlexBoxStyler.shadows/StackBoxStyler.shadows/TextStyler.shadowsfactory signatures to match.packages/mix_tailwinds/lib/src/tw_parser.dartBoxShadowListMix(...)/ShadowListMix(...)before forwarding to the styler.packages/mix/test/...packages/mix/test/src/theme/tokens/shadow_list_token_integration_test.darttoken.mix()and*ListMixliteral flows.packages/mix/CHANGELOG.mdMigration
The same wrapping applies to
BoxStyler.shadows(...),FlexBoxStyler.shadows(...),StackBoxStyler.shadows(...), andTextStyler.shadows(...).Test plan
dart analyze .clean across all workspace packages (mix,mix_annotations,mix_generator,mix_lint,mix_tailwinds,mix_tailwinds_example).flutter testinpackages/mix: 2726/2726 passing.flutter testinpackages/mix_tailwinds: 322/322 passing.shadow_list_token_integration_test.dart:BoxShadowToken.mix()returns aBoxShadowListMixRefthat satisfies theBoxShadowListMixinterface.BoxStyler().boxShadows(token.mix())compiles and produces a styler with the token-backed shadow prop.BoxStyler().shadows(token.mix())(theDecorationStyleMixinpath) compiles and produces a styler.BoxStyler().shadows(BoxShadowListMix([...]))literal form works.MixScoperesolve:boxShadowToken.mix()resolves to the configuredList<BoxShadow>at render time.TextStyler().shadows(shadowToken.mix())and theShadowListMix([...])literal form for text shadows.