Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep nested copy #92

Open
tolotrasamuel opened this issue May 26, 2024 · 1 comment
Open

Deep nested copy #92

tolotrasamuel opened this issue May 26, 2024 · 1 comment

Comments

@tolotrasamuel
Copy link

tolotrasamuel commented May 26, 2024

Describe the issue

With the freezed package, I was able to able copy the Company model by changing only the name of the assistant director with one single line.

Company company;

Company newCompany = company.copyWith.director.assistant(name: 'John Smith');

To the best of my knowledge, this is not possible with copy_with_extension , because director is a function .

It will be great if you could add the same feature parity as freezed since you package focus solely on the copy with extension, people expect it to be at least on par with freezed copyWith capability

Environment details

Paste the flutter environment detail.

flutter doctor
flutter --version
3.19.3

Paste the package version.

dependencies:
  copy_with_extension: 5.0.4

To Reproduce
Without any library, the following is cumbersome:

Company company;

Company newCompany = company.copyWith(
  director: company.director.copyWith(
    assistant: company.director.assistant.copyWith(
      name: 'John Smith',
    ),
  ),
);

Expected behaviour

With the freezed package, I was able to able copy the Company model by changing only the name of the assistant director with one single line.

Company company;

Company newCompany = company.copyWith.director.assistant(name: 'John Smith');

To the best of my knowledge, this is not possible with copy_with_extension , because director is a function .

It will be great if you could the same feature parity as freezed since you package focus solely on the copy with extension, people expect it to be at least on par with freezed copyWith capability

Additional context

For reference, freezed , freezed uses classes on thecompany.copyWith.director. generated code and overrides the call method, instead of a function

@f-person
Copy link

f-person commented Aug 1, 2024

Just came here to write this. I don't really like freezed, so I also solely rely on copy_with_extension to get my copyWith methods. So yeah, this would be awesome indeed (otherwise, the code is really boilerplate-y with nested stuff)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants