Writing summary categories and the use of Freezed

Hello there!

I am posting this right here as this pertains to the Dart lang. I attempted my highest to unravel this by myself but it surely seems like I am not able to get thru.

Say I’ve the next scenario:

summary elegance SuperClass {
String get identification;
// … one thing extra I will’t determine, see beneath

elegance A extends SuperClass {…}
elegance X extends SuperClass {…}
elegance Y extends SuperClass {…}
elegance Z extends SuperClass {…}

elegance B {
const B(myValue);
ultimate superClass myValue;

ultimate b = B(A());
ultimate price = b.myValue.copyWith(…);

The former instance displays a freelance (`SuperClass`) and 4 other conceivable concrete implementations (`A`, `X`, `Y`, and `Z`); `B` is simply the use of any such 4 conceivable concrete implementations. I want to get entry to the interior price, `myValue`, and their strategies, when developing `B` items.

My drawback is: *how can I enforce this* the use of `Freezed` at the imposing subclasses of `SuperClass`, whilst keeping up those relationships?

The catch, which is what I *in point of fact* want, is the the final line within the earlier code. I principally want to enforce an interface of Freezed items, however I am unaware of the way can I as it should be reach that with out breaking codegen.

Sure, I have learn the [documentation](https://pub.dev/packages/freezed#mixins-and-interfaces-for-individual-classes-for-union-types) about it. However as I attempted, all my makes an attempt lead me to mistaken / uncompilable code. This must in point of fact be a very easy job, however I will’t pop out of it. My failed makes an attempt come with:

* The use of the `Implements<SuperClass>` annotation;
* The use of `@JsonSerializable` onto the superclass;
* The use of the `@Mixin<SuperClass` annotation;
* Writing `fromJson`, `toJson`, `copyWith` (and extra) in `SuperClass`.

I attempted asking this query to [SO](https://stackoverflow.com/questions/74212270/writing-abstract-classes-while-using-freezed), however I had no success but.

If any individual may assist it could be very much favored.

View Reddit by way of venir_devView Supply

You may also like...

WP2Social Auto Publish Powered By : XYZScripts.com