Skip to content

feat(mix_generator): add @MixableModifier annotation and generator#897

Open
tilucasoli wants to merge 14 commits intomainfrom
tilucasoli/gen-modifiers
Open

feat(mix_generator): add @MixableModifier annotation and generator#897
tilucasoli wants to merge 14 commits intomainfrom
tilucasoli/gen-modifiers

Conversation

@tilucasoli
Copy link
Copy Markdown
Collaborator

Related issue

N/A - new feature

Description

Adds a @MixableModifier() annotation and code generator that automatically generates ModifierMix classes from WidgetModifier subclasses. This eliminates ~30-40 lines of boilerplate per modifier (resolve, merge, debugFillProperties, props, constructors). The generator uses the existing MixTypeRegistry to determine Prop.maybe vs Prop.maybeMix wrapping.

Changes

  • mix_annotations: Added MixableModifier annotation class
  • mix_generator: Added ModifierGenerator (triggers on @MixableModifier) and ModifierMixBuilder (generates full standalone ModifierMix class)
  • mix_generator/build.yaml: Registered modifier_generator builder for lib/src/modifiers/**/*.dart
  • mix: Applied @MixableModifier() to OpacityModifier as proof-of-concept, replacing the hand-written OpacityModifierMix with a generated one
  • Tests: 11 new unit tests for ModifierMixBuilder, all 3736 existing mix tests pass

Review Checklist

  • Testing: Have you tested your changes, including unit tests and integration tests for affected code?
  • Breaking Changes: Does this change introduce breaking changes affecting existing code or users?
  • Documentation Updates: Are all relevant documentation files (e.g. README, API docs) updated to reflect the changes in this PR?
  • Website Updates: Is the website containing the updates you make on documentation?

Additional Information (optional)

Breaking change: OpacityModifier constructor changed from positional ([double? opacity]) to named ({double? opacity}) to support the generated resolve() pattern. Complex modifiers with non-1:1 field mappings (Scale, Rotate, Skew, Transform) are out of scope and remain hand-written.

tilucasoli and others added 7 commits April 13, 2026 22:46
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…x classes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replaces the hand-written OpacityModifierMix with a generated one.
Constructor changed from positional to named params.

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

docs-page bot commented Apr 14, 2026

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

docs.page/btwld/mix~897

Documentation is deployed and generated using docs.page.

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 14, 2026

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

Project Deployment Actions Updated (UTC)
mix-docs Ready Ready Preview, Comment Apr 15, 2026 1:39am

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…difiers

WidgetModifier constructors use positional params, so the generated
resolve() now calls them with positional args instead of named args.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tilucasoli and others added 2 commits April 14, 2026 01:44
Replace hand-written ModifierMix classes with code generation for 19
modifiers across 14 files. Update generator to support named constructor
params and fix single-cascade lint warning.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ugFillProperties, props

Add ModifierMixinBuilder that generates _$XModifierMethods mixin for
@MixableModifier annotated classes, replacing hand-written copyWith,
lerp, debugFillProperties, and props methods across all 19 modifier
classes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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