Skip to content

PoC: BoxStylerWrapper for variant-aware resolution#892

Closed
tilucasoli wants to merge 1 commit into
mainfrom
tilucasoli/box-styler-wrapper
Closed

PoC: BoxStylerWrapper for variant-aware resolution#892
tilucasoli wants to merge 1 commit into
mainfrom
tilucasoli/box-styler-wrapper

Conversation

@tilucasoli

Copy link
Copy Markdown
Collaborator

Summary

This is a Proof of Concept that changes the way a Styler is resolved.

Problem

Currently, variants live in a separate list inside the Styler. During resolution, they are merged only among themselves and applied at the end, after all other properties. This means context variants (like useToken) don't participate at the same level as regular properties — tokens work with reference values before the real resolved ones are available.

Approach

BoxStylerWrapper introduces an intermediate resolution layer that:

  • Holds a list of BoxStyler layers independently (wrapping instead of merging)
  • Resolves variants per layer before merging layers together
  • Resolves all token references to concrete values

This guarantees that context variants like useToken are resolved at the same time as other properties, ensuring tokens work with actual resolved values rather than references.

Changes

  • BoxStylerWrapper — new class in specs/box/ that wraps a list of BoxStyler and resolves them into a single BoxStyler with concrete values
  • useToken — new method on VariantStyleMixin that resolves a token and passes the concrete value to a builder
  • mergeActiveVariants — changed from @visibleForTesting to @internal for package-level access
  • theme_tokens.dart — updated example demonstrating the wrapper + useToken pattern

Test plan

  • Validate that tokens resolve correctly through BoxStylerWrapper.resolve()
  • Validate that context variants are applied per layer before merging
  • Validate that useToken resolves token values eagerly

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@docs-page

docs-page Bot commented Apr 7, 2026

Copy link
Copy Markdown

To view this pull requests documentation preview, visit the following URL:

docs.page/btwld/mix~892

Documentation is deployed and generated using docs.page.

@vercel

vercel Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mix-docs Ready Ready Preview, Comment Apr 7, 2026 3:22am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant