dart_mappable icon indicating copy to clipboard operation
dart_mappable copied to clipboard

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

Open P1Rh0 opened this issue 1 year ago • 3 comments

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 :)

P1Rh0 avatar Apr 29 '24 18:04 P1Rh0

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

schultek avatar Apr 30 '24 06:04 schultek

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

P1Rh0 avatar Apr 30 '24 12:04 P1Rh0

You could also maybe hide it from the dart_mappble import

schultek avatar Apr 30 '24 13:04 schultek