schultek / dart_mappable

Improved json serialization and data classes with full support for generics, inheritance, customization and more.
https://pub.dev/packages/dart_mappable
MIT License
153 stars 23 forks source link

Unable to create an Item class - The name 'ItemCopyWith' is defined in the libraries... #190

Open P1Rh0 opened 5 months ago

P1Rh0 commented 5 months ago

Not sure if this is really a problem or its just a namespace we can't use (happy if that's the case).

When I create an Item MappableClass

@MappableClass()
class Item with ItemMappable {
   ...
}

and then use it

@MappableClass()
class OtherClass with OtherClassMappable {
  List<Item> items;

  OtherClass(this.items);
}

the mapper file created for OtherClass has the error:

The name 'ItemCopyWith' is defined in the libraries 'package:dart_mappable/src/copy_with/list_copy_with.dart' and 'package:my/package/item.dart'

Is it possible to rename the internals to make it less likely to have this clash (and possibly others?) or should I just rename my class and treat it as a keyword?

Thanks :)

schultek commented 5 months ago

I will not be able to rename this since it would be a major braking change for all users.

You can try giving the import of Item a prefix, I think the builder would respect prefixes (I think ... its been a long time since I wrote this code 😅)

If that doesn't work you would have to rename the Item class

P1Rh0 commented 5 months ago

Ah ok I hoped it might just be something used internally, nevermind :) Thanks for the rapid reply :)

schultek commented 5 months ago

You could also maybe hide it from the dart_mappble import