numen31337/copy_with_extension

support default values

JoseGeorges8 opened this issue · 1 comments

I would like to copy a class with a default value if none is passed instead of copying that value.

e.g

MyClass.copyWith(bool myBoolean)  => MyClass(myBoolean: myBoolean ?? false);

This could be a parameter for @CopyWithField called default

Is very useful since I have state classes that show loading indicators depending on a loading boolean, and instead of passing loading: false I can simply ignore it.

Does this seem like an useful feature for the package? Thanks!

Hello @JoseGeorges8 and thank you for the feature suggestion. I think it is better to avoid such features as it will introduce some implicit behaviour to what you would expect from a copyWith function. It will literally introduce a side-effect to this function which in my opinion will do more harm than good.