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

[Feature Request] Use freezed for models #406

Closed
Cierra-Runis opened this issue May 17, 2024 · 2 comments
Closed

[Feature Request] Use freezed for models #406

Cierra-Runis opened this issue May 17, 2024 · 2 comments

Comments

@Cierra-Runis
Copy link

Freezed is a code generator for data-classes/unions/pattern-matching/cloning.

At frist I want to print the full content of model classes, I use toJson() and its output like:

{commit: Instance of 'RepositoryCommit', content: Instance of 'GitHubFile'}

It can't print full content. With freezed, we can solve this issue.

Freezed has other benefits too, it prevent mutable classes and provide union types.

Freezed doesn't support extend or implement another Freezed class yet, but we can use it for some smaller classes.

Copy link

👋 Thanks for reporting! @robrbecker will take a look.

@robrbecker
Copy link
Member

Hi @Cierra-Runis and thanks for filing an issue. I'd like to break down my response into 2 areas.

  1. Printing the full contents of a RepositoryCommit
  2. Using Freezed

If your main use case is for printing / debugging classes, I'd suggest another approach. It could be something like:

  • a utility method or collection of utility methods in your code for printing your desired output and passing in the RepositoryCommit you'd like to print

I'd rather not add another code generation library on top of or instead of JsonSerializable, especially with macros coming to Dart. There's a big opportunity to rethink and simplify this library once macros are A Thing™.

If you're ok with implementing something on your end until then, I'll probably close this issue and link it to a new one about using macros when they are available.

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

No branches or pull requests

2 participants