dart_mappable icon indicating copy to clipboard operation
dart_mappable copied to clipboard

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

Open nikodembernat opened this issue 9 months ago • 1 comments

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: https://github.com/schultek/dart_mappable/issues/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.

nikodembernat avatar Mar 12 '25 11:03 nikodembernat