Skip to content

Third-party libraries that depend on dart_mappable without exporting mappers break code generation #278

@nikodembernat

Description

@nikodembernat

Issue

Let's assume we have a 3rd party package:some_package that depends on dart_mappable to generate model classes. That package then exports models, but hides mappers to avoid polluting the autocomplete (see: #91).

Now, let's move to our app. We create a class that uses those exported models in our own dart_mappable class. The current implementation fails during code generation, because the 3rd party library doesn't export *Mapper and *CopyWith classes, but expects them since those models are annotated with @MappableClass().

Related repository

n-bernat/dart_mappable-issue278

Possible solution

Since we can add custom mappers to @MappableClass() (e.g. @MappableClass(includeCustomMappers: [_SomeMapper()]), it seems feasible to use provided custom mappers (if we have them), instead of generating new ones.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions