Skip to content

fix(builder): Support linked mappers in extension types - #351

Open
DaPotatoMan wants to merge 1 commit into
schultek:mainfrom
DaPotatoMan:main
Open

DaPotatoMan wants to merge 1 commit into
schultek:mainfrom
DaPotatoMan:main

Conversation

@DaPotatoMan

@DaPotatoMan DaPotatoMan commented Jul 22, 2026 •

Copy link
Copy Markdown

Summary

Adds mapper dependency discovery for extension types.
Related to #348

Problem

extension type const ModelList(List<NestedModel> value) implements List<NestedModel> {}

@MappableClass()
class ParentModel with ParentModelMappable {
  final ModelList models;
}

Previously, ParentModelMapper only saw ModelList, so it did not initialize NestedModelMapper.

Solution

The builder now checks an extension type’s wrapped type when finding linked mappers. In this example, it finds List<NestedModel> and adds:

NestedModelMapper.ensureInitialized();

ParentModel.models remains typed as ModelList.

Testing

  • Added a generator test for extension-type fields.
  • Verified generated fields keep their extension type.
  • Ran dart test packages/dart_mappable_builder/test/simple_model_test.dart.

AI-assisted, then reviewed, verified, and tested.

If you need this fix while using 4.7.0 or 4.8.0, it is also available on the 4.7.0-fix branch and the 4.8.0-fix branch.

@DaPotatoMan

Copy link
Copy Markdown
Author

@schultek I’ve rebased this PR onto the latest main and verified that everything is working as expected. When you have a chance, could you take a look?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant