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
164 stars 23 forks source link

Generate `copyWith` etc without generating `fromJson` etc #201

Closed caseycrogers closed 4 months ago

caseycrogers commented 5 months ago

I mostly use dart mappable for classes that I want to (de)serialize. However, sometimes, I just need copyWIth etc for a class that I don't intend to serialize/deserialize.

I can either user dart_mappable and ignore the generated serialization related methods (not ideal because the class may not even be coherently serializable eg if it needs custom mappers for some of its attributes) or use another package (also not ideal because now I have two different packages with different syntax for doing roughly the same thing).

Ideally, I could just specify a false bool flag in the annotation that would tell dart mappable to skip generating serialization related methods.

schultek commented 5 months ago

I got you: https://pub.dev/documentation/dart_mappable/latest/topics/Configuration-topic.html#generation-methods