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

Is there a way of defining multiple converters in Freezed constructor. #1127

Open
haodong404 opened this issue Sep 26, 2024 · 1 comment
Open
Assignees
Labels
enhancement New feature or request needs triage

Comments

@haodong404
Copy link

Like JsonSerializable, we can define many converters using the argument converters.

@JsonSerializable(converters: [DateTimeConverter(), IntConverter()])

But Freezed does not have the same argument. So, I'm wondering if there's a convenient way to set up a lot of converters.

@haodong404
Copy link
Author

I noticed that define a @JsonSerializable above the factory constructor in a Freezed class can solve this problem.

class Test with _$Test {
  @JsonSerializable(converters: [DateTimeConverter(), IntConverter()])
  const factory Test( {
    int? id,
  });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs triage
Projects
None yet
Development

No branches or pull requests

2 participants