-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
Separate between Data Class and Sealed Class #587
Comments
Inheriting Freezed classes is not supported. |
Do you mean that I am not able to extend my freezed data classes with any other class? |
Even without the need for "super", it's still not supported to subclass freezed classed As you've seen, you'll get a clash on various properties like copyWith and possibly the when/map functions |
It actually compiles fine if there are no name collisions. Am I missing something here? In the previous screenshot, it's not compiling because the generated freezed mixin has a |
Closing in favor of #636 |
Reopening #576
As the title say, a condition to generate only Data Class or Sealed Class would be really helpful for those looking for only one of the use case.
Now, to get to the actual issue that I was facing:
This was the precise message that the compiler was showing: Try adjusting the supertypes of this class to remove the inconsistency.dart(inconsistent_inheritance_getter_and_method)
The class the I am extending from, let's call it class Parent, already has a
copyWith
method. (As classes often do.) The external Parent class is not in my control, so I cannot remove or shadow thecopyWith
method from it. But the freezed class is something that I have control over so I argue for separation between data & sealed class. Or maybe make it optional in the same waymaybeWhen
andmaybeMap
are.I did try some other workaround but didn't find any way to shadow the
copyWith
method.To be precise, I tried make it protected with the @Protected annotation but was of no help. And I don't think there's any way of choosing which method to use when using inheritance.
I am currently at a roadblock so if anyone has previously solved parent classes that expose a method with a same name.
The text was updated successfully, but these errors were encountered: