Skip to content
Discussion options

You must be logged in to vote

I figured out what was causing the issue!

This code used to work fine in freezed version 2.5.8, but after updating, I started getting an error like:

Could not generate _$PersonFromJson because both Person and _Person would want to generate it.
Rename one or the other, such that they don't conflict.

It turns out the problem is that both factory constructors were trying to generate the same class name (_Person), which causes a conflict when generating the _$PersonFromJson method.

✅ What worked for me:

I changed the names of the generated classes to make them unique:

@freezed
sealed class Person with _$Person {

  const factory Person({
    required String firstName,
    required String la…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@devthigas502
Comment options

Answer selected by devthigas502
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants