Skip to content

fix(mix_generator): Respect nullability in lerp and update deps#849

Merged
tilucasoli merged 5 commits intomainfrom
fix/optional-lerp-resolver
Feb 6, 2026
Merged

fix(mix_generator): Respect nullability in lerp and update deps#849
tilucasoli merged 5 commits intomainfrom
fix/optional-lerp-resolver

Conversation

@tilucasoli
Copy link
Collaborator

Related issue

N/A

Description

This PR fixes the LerpResolver to correctly handle nullable vs non-nullable fields when generating lerp code, and makes copyWith parameters properly optional. Additionally, it relaxes dependency constraints for better compatibility.

Changes

LerpResolver nullability fix:

  • Use ?. operator for nullable fields ($name?.lerp(other?.$name, t))
  • Use . operator for non-nullable fields ($name.lerp(other?.$name, t))

copyWith optional parameters:

  • Make all copyWith parameters nullable/optional, regardless of field nullability
  • Non-nullable types like String become String? in copyWith signature
  • This allows partial updates without requiring all fields

Dependency updates (mix_generator):

  • Relaxed version constraints for analyzer, build, source_gen, build_config, collection, and dart_style
  • Removed analyzer from root pubspec.yaml

Testing:

  • Added unit tests for nullable and non-nullable delegate cases in lerp_resolver_test.dart
  • Added comprehensive tests for copyWith parameter optionality in spec_mixin_builder_test.dart

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)

The dependency version changes improve compatibility with different Flutter/Dart SDK versions while still maintaining the required functionality.

Made with Cursor

Ensure copyWith parameters are always optional by making their types nullable: SpecMixinBuilder now appends a '?' to parameter types that are not already nullable. Add comprehensive unit tests covering nullable and non-nullable fields, mixed types, complex types, list types, null-coalescing usage in the copyWith body, and prevention of double '??' suffix. The tests introduce test helpers (createTestFieldModel) and minimal fake implementations (_FakeDartType, _FakeFieldElement) to exercise FieldModel-driven code generation.
Make LerpResolver choose the correct call operator for delegate-based lerp: use ?. for nullable fields and . for non-nullable fields (adds an isNullable check). Update unit tests to cover both nullable and non-nullable delegate cases. Relax and adjust dependency ranges in packages/mix_generator/pubspec.yaml for analyzer, build, source_gen, build_config, collection and dart_style to improve compatibility. Remove analyzer from the root pubspec dependencies.
@docs-page
Copy link

docs-page bot commented Feb 6, 2026

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

docs.page/btwld/mix~849

Documentation is deployed and generated using docs.page.

@vercel
Copy link
Contributor

vercel bot commented Feb 6, 2026

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

Project Deployment Actions Updated (UTC)
mix-docs Ready Ready Preview, Comment Feb 6, 2026 1:56am

@tilucasoli tilucasoli merged commit 23fbf2b into main Feb 6, 2026
7 checks passed
@tilucasoli tilucasoli deleted the fix/optional-lerp-resolver branch February 6, 2026 02:00
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