fix(generator): support generic @MixWidget call methods#958
Merged
Conversation
206fd12 to
39e60af
Compare
Also adds a validation test for call type parameter bounds that aren't visible from the annotated library, a path that previously had no coverage.
5 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates mix_generator’s @MixWidget support to allow generating widgets from generic styler call<T>() methods, preserving type parameter bounds on the generated widget class and forwarding type arguments when invoking the styler call—unblocking generic Remix/Fortal-style APIs like FortalRadio<T>.
Changes:
- Extend
MixWidgetGeneratorto accept genericcall<T>()methods when the return type is Widget-assignable (includingT extends Widget), and validate type-parameter bound visibility. - Add
callTypeParamsplumbing to the model/builder to emit generic widget classes and forward.call<T>()invocations. - Add integration + unit test coverage for success cases and key rejection paths (non-widget bounds, hidden bound types, prefixed Flutter imports).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/mix_generator/lib/src/mix_widget_generator.dart | Accepts/validates generic call<T>(), extracts type params/bounds, and enforces bound visibility + unprefixed Flutter base symbols. |
| packages/mix_generator/lib/src/core/models/mix_widget_model.dart | Adds WidgetCallTypeParam + model helpers for class generic declarations and call invocations. |
| packages/mix_generator/lib/src/core/builders/mix_widget_builder.dart | Emits generic widget class declarations and forwards type args on .call<...>(). |
| packages/mix_generator/test/integration/generator_smoke_test.dart | Adds end-to-end smoke tests asserting generated output for generic widgets and forwarded type args. |
| packages/mix_generator/test/integration/generator_validation_test.dart | Adds validation tests for invalid generic-return shapes and bound visibility/import constraints. |
| packages/mix_generator/test/core/builders/mix_widget_builder_test.dart | Adds unit tests for generic class emission, bound preservation, and type-arg forwarding in the builder. |
| packages/mix_generator/pubspec.yaml | Bumps package version to 2.1.2. |
| packages/mix_generator/CHANGELOG.md | Documents the new fix in 2.1.2. |
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.
Summary
@MixWidgetto generate widgets from generic stylercall<T>()methodsWhy
Remix needs generated Fortal widgets for generic radio and accordion APIs, e.g.
FortalRadio<T>andFortalAccordion<T>. The published generator rejects genericcall()methods today, which blocks reproducible code generation and pushes consumers toward hand-written widget drift.Fixes #957.
Validation
fvm dart pub getfvm dart testfrompackages/mix_generatorpasses, 277 tests